Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a4b392d1
authored
Mar 17, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-106' into 'master'
Locale support
#106
parents
6fcdec33
3123a887
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
11 deletions
+92
-11
circle/circle/settings/base.py
+1
-0
circle/dashboard/forms.py
+19
-0
circle/dashboard/models.py
+4
-0
circle/dashboard/templates/dashboard/base.html
+7
-4
circle/dashboard/templates/dashboard/profile_form.html
+20
-0
circle/dashboard/urls.py
+6
-4
circle/dashboard/views.py
+35
-3
No files found.
circle/circle/settings/base.py
View file @
a4b392d1
...
...
@@ -192,6 +192,7 @@ MIDDLEWARE_CLASSES = (
# Default Django middleware.
'django.middleware.common.CommonMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.locale.LocaleMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
...
...
circle/dashboard/forms.py
View file @
a4b392d1
...
...
@@ -22,6 +22,7 @@ from storage.models import Disk, DataStore
from
vm.models
import
(
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
)
from
.models
import
Profile
VLANS
=
Vlan
.
objects
.
all
()
DISKS
=
Disk
.
objects
.
exclude
(
type
=
"qcow2-snap"
)
...
...
@@ -991,3 +992,21 @@ class TraitForm(forms.ModelForm):
class
Meta
:
model
=
Trait
fields
=
[
'name'
]
class
MyProfileForm
(
forms
.
ModelForm
):
class
Meta
:
fields
=
(
'preferred_language'
,
)
model
=
Profile
@property
def
helper
(
self
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
'preferred_language'
,
)
helper
.
add_input
(
Submit
(
"submit"
,
_
(
"Save"
)))
return
helper
def
save
(
self
,
*
args
,
**
kwargs
):
value
=
super
(
MyProfileForm
,
self
)
.
save
(
*
args
,
**
kwargs
)
return
value
circle/dashboard/models.py
View file @
a4b392d1
...
...
@@ -4,6 +4,7 @@ from logging import getLogger
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.signals
import
user_logged_in
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
(
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
,
DateTimeField
,
...
...
@@ -69,6 +70,9 @@ class Profile(Model):
return
Notification
.
send
(
self
.
user
,
subject
,
template
,
context
,
valid_until
)
def
get_absolute_url
(
self
):
return
reverse
(
"dashboard.views.profile"
)
class
GroupProfile
(
AclBase
):
ACL_LEVELS
=
(
...
...
circle/dashboard/templates/dashboard/base.html
View file @
a4b392d1
...
...
@@ -36,12 +36,15 @@
{% block navbar-ul %}
{% endblock %}
</ul>
<a
class=
"navbar-brand pull-right"
href=
"/network/"
style=
"color: white; font-size: 10px;"
>
Network
</a>
<a
class=
"navbar-brand pull-right"
href=
"/admin/"
style=
"color: white; font-size: 10px;"
>
Admin
</a>
{% if user.is_authenticated %}
<a
class=
"navbar-brand pull-right"
href=
"{% url "
logout
"
%}?
next=
{%
url
"
login
"
%}"
style=
"color: white; font-size: 10px;"
>
Log out {{user}}
</a>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
logout
"
%}?
next=
{%
url
"
login
"
%}"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-signout icon-sign-out"
></i>
{% trans "Log out" %}
</a>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
dashboard
.
views
.
profile
"
%}"
title=
"{% trans "
User
profile
"
%}"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-user "
></i>
{{user}}
</a>
<a
class=
"navbar-brand pull-right"
href=
"/network/"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-globe"
></i>
{% trans "Network" %}
</a>
{% if user.is_superuser %}
<a
class=
"navbar-brand pull-right"
href=
"/admin/"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-cogs"
></i>
{% trans "Admin" %}
</a>
{% endif %}
{% else %}
<a
class=
"navbar-brand pull-right"
href=
"{% url "
login
"
%}?
next=
{%
url
"
dashboard
.
index
"
%}"
style=
"color: white; font-size: 10px;"
>
Login
</a>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
login
"
%}?
next=
{%
url
"
dashboard
.
index
"
%}"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-sign-in"
></i>
{% trans "Log in " %}
</a>
{% endif %}
</div>
<!-- .collapse .navbar-collapse -->
</div>
<!-- navbar navbar-inverse navbar-fixed-top -->
...
...
circle/dashboard/templates/dashboard/profile_form.html
0 → 100644
View file @
a4b392d1
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
index
"
%}"
>
{% trans "Back" %}
</a>
<h3
class=
"no-margin"
><i
class=
"icon-desktop"
></i>
{% trans "My profile" %}
</h3>
</div>
<div
class=
"panel-body"
>
{% crispy form %}
</div>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
a4b392d1
...
...
@@ -4,10 +4,10 @@ from vm.models import Instance
from
.views
import
(
AclUpdateView
,
DiskAddView
,
FavouriteView
,
GroupAclUpdateView
,
GroupDelete
,
GroupDetailView
,
GroupList
,
GroupUserDelete
,
IndexView
,
LeaseCreate
,
LeaseDelete
,
LeaseDetail
,
NodeAddTraitView
,
NodeCreate
,
NodeDele
te
,
NodeDe
tailView
,
NodeGraphView
,
NodeList
,
NodeStatus
,
NotificationView
,
PortDelete
,
TemplateAclUpdateView
,
TemplateCreate
,
TemplateDele
te
,
TemplateDetail
,
TemplateList
,
TransferOwnershipConfirmView
,
LeaseDelete
,
LeaseDetail
,
MyPreferencesView
,
NodeAddTraitView
,
NodeCrea
te
,
NodeDe
lete
,
NodeDetailView
,
NodeGraphView
,
NodeList
,
NodeStatus
,
NotificationView
,
PortDelete
,
TemplateAclUpdateView
,
TemplateCrea
te
,
TemplateDe
lete
,
TemplateDe
tail
,
TemplateList
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenewView
,
...
...
@@ -97,4 +97,6 @@ urlpatterns = patterns(
url
(
r'^disk/add/$'
,
DiskAddView
.
as_view
(),
name
=
"dashboard.views.disk-add"
),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
name
=
"dashboard.views.profile"
),
)
circle/dashboard/views.py
View file @
a4b392d1
...
...
@@ -34,8 +34,8 @@ from braces.views import (
)
from
.forms
import
(
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
Nod
eForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
MyProfil
eForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
)
from
.tables
import
(
NodeListTable
,
NodeVmListTable
,
TemplateListTable
,
LeaseListTable
,
GroupListTable
,)
...
...
@@ -1999,8 +1999,10 @@ def circle_login(request):
extra_context
=
{
'saml2'
:
hasattr
(
settings
,
"SAML_CONFIG"
)
}
re
turn
login
(
request
,
authentication_form
=
authentication_form
,
re
sponse
=
login
(
request
,
authentication_form
=
authentication_form
,
extra_context
=
extra_context
)
set_language_cookie
(
request
,
response
)
return
response
class
DiskAddView
(
TemplateView
):
...
...
@@ -2042,3 +2044,33 @@ class DiskAddView(TemplateView):
r
=
obj
.
get_absolute_url
()
r
=
"
%
s#resources"
%
r
return
redirect
(
r
)
class
MyPreferencesView
(
UpdateView
):
model
=
Profile
form_class
=
MyProfileForm
def
get_object
(
self
,
queryset
=
None
):
if
self
.
request
.
user
.
is_anonymous
():
raise
PermissionDenied
()
try
:
return
self
.
request
.
user
.
profile
except
Profile
.
DoesNotExist
:
raise
Http404
(
_
(
"You don't have a profile."
))
def
form_valid
(
self
,
form
):
response
=
super
(
MyPreferencesView
,
self
)
.
form_valid
(
form
)
set_language_cookie
(
self
.
request
,
response
)
return
response
def
set_language_cookie
(
request
,
response
,
lang
=
None
):
if
lang
is
None
:
try
:
lang
=
request
.
user
.
profile
.
preferred_language
except
:
return
cname
=
getattr
(
settings
,
'LANGUAGE_COOKIE_NAME'
,
'django_language'
)
response
.
set_cookie
(
cname
,
lang
,
365
*
86400
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment