Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c1cb2807
authored
Jun 17, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-profile-rework' into 'master'
Feature Profile Rework
parents
e561b9eb
561ab759
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
20 deletions
+59
-20
circle/dashboard/forms.py
+9
-1
circle/dashboard/migrations/0009_use_gravatar_default_true.py
+0
-0
circle/dashboard/models.py
+26
-1
circle/dashboard/templates/base.html
+1
-1
circle/dashboard/templates/dashboard/profile.html
+1
-1
circle/dashboard/templates/dashboard/profile_form.html
+20
-4
circle/dashboard/views.py
+2
-12
No files found.
circle/dashboard/forms.py
View file @
c1cb2807
...
...
@@ -46,6 +46,12 @@ from vm.models import (
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
)
from
.models
import
Profile
,
GroupProfile
from
circle.settings.base
import
LANGUAGES
from
django.utils.translation
import
string_concat
LANGUAGES_WITH_CODE
=
((
l
[
0
],
string_concat
(
l
[
1
],
" ("
,
l
[
0
],
")"
))
for
l
in
LANGUAGES
)
class
VmSaveForm
(
forms
.
Form
):
...
...
@@ -1051,9 +1057,11 @@ class TraitForm(forms.ModelForm):
class
MyProfileForm
(
forms
.
ModelForm
):
preferred_language
=
forms
.
ChoiceField
(
LANGUAGES_WITH_CODE
)
class
Meta
:
fields
=
(
'preferred_language'
,
'email_notifications'
,
)
fields
=
(
'preferred_language'
,
'email_notifications'
,
'use_gravatar'
,
)
model
=
Profile
@property
...
...
circle/dashboard/migrations/0009_use_gravatar_default_true.py
0 → 100644
View file @
c1cb2807
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
c1cb2807
...
...
@@ -18,6 +18,7 @@
from
__future__
import
absolute_import
from
itertools
import
chain
from
hashlib
import
md5
from
logging
import
getLogger
from
django.conf
import
settings
...
...
@@ -29,6 +30,7 @@ from django.db.models import (
DateTimeField
,
permalink
,
BooleanField
)
from
django.template.loader
import
render_to_string
from
django.templatetags.static
import
static
from
django.utils.translation
import
ugettext_lazy
as
_
,
override
,
ugettext
from
model_utils.models
import
TimeStampedModel
...
...
@@ -83,7 +85,9 @@ class Profile(Model):
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
instance_limit
=
IntegerField
(
default
=
5
)
use_gravatar
=
BooleanField
(
default
=
False
)
use_gravatar
=
BooleanField
(
verbose_name
=
_
(
"Use Gravatar"
),
default
=
True
,
help_text
=
_
(
"Whether to use email address as Gravatar profile image"
))
email_notifications
=
BooleanField
(
verbose_name
=
_
(
"Email notifications"
),
default
=
True
,
help_text
=
_
(
'Whether user wants to get digested email notifications.'
))
...
...
@@ -96,6 +100,27 @@ class Profile(Model):
return
reverse
(
"dashboard.views.profile"
,
kwargs
=
{
'username'
:
self
.
user
.
username
})
def
get_avatar_url
(
self
):
if
self
.
use_gravatar
:
gravatar_hash
=
md5
(
self
.
user
.
email
)
.
hexdigest
()
return
(
"https://secure.gravatar.com/avatar/
%
s"
"?s=200"
%
gravatar_hash
)
else
:
return
static
(
"dashboard/img/avatar.png"
)
def
get_display_name
(
self
):
if
self
.
user
.
get_full_name
():
name
=
self
.
user
.
get_full_name
()
else
:
name
=
self
.
user
.
username
if
self
.
org_id
:
name
=
"
%
s (
%
s)"
%
(
name
,
self
.
org_id
)
return
name
def
__unicode__
(
self
):
return
self
.
get_display_name
()
class
GroupProfile
(
AclBase
):
ACL_LEVELS
=
(
...
...
circle/dashboard/templates/base.html
View file @
c1cb2807
...
...
@@ -49,7 +49,7 @@
</ul>
{% if user.is_authenticated and user.pk %}
<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
"
username=
user.username
%}"
<a
class=
"navbar-brand pull-right"
href=
"{% url "
dashboard
.
views
.
profile
-preferences
"
%}"
title=
"{% trans "
User
profile
"
%}"
style=
"color: white; font-size: 10px;"
>
<i
class=
"icon-user"
></i>
{% include "dashboard/_display-name.html" with user=user show_org=True %}
...
...
circle/dashboard/templates/dashboard/profile.html
View file @
c1cb2807
...
...
@@ -38,7 +38,7 @@
{%
if
profile
.
profile
.
use_gravatar
%}
checked=
"checked"
{%
endif
%}
type=
"checkbox"
/>
<a
href=
"https://gravatar.com"
>
{% trans "What's Gravatar?" %}
</a>
</p>
<a
href=
"{% url "
dashboard
.
views
.
profile-preferences
"
%}"
>
{% trans "Change
password and language
" %}
</a>
<a
href=
"{% url "
dashboard
.
views
.
profile-preferences
"
%}"
>
{% trans "Change
my preferences
" %}
</a>
{% endif %}
</div>
<div
class=
"clearfix"
></div>
...
...
circle/dashboard/templates/dashboard/profile_form.html
View file @
c1cb2807
...
...
@@ -10,23 +10,39 @@
<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>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
profile
"
username=
object.user.username
%}"
>
{% trans "Go to my profile" %}
</a>
<h3
class=
"no-margin"
><i
class=
"icon-desktop"
></i>
{% trans "My profile" %}
</h3>
</div>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"col-
sm
-4"
style=
"margin-bottom: 50px;"
>
<div
class=
"col-
md
-4"
style=
"margin-bottom: 50px;"
>
<fieldset>
<legend>
{% trans "Password change" %}
</legend>
{% crispy forms.change_password %}
</fieldset>
</div>
<div
class=
"col-
sm-offset-5 col-sm-3
"
>
<div
class=
"col-
md-4"
style=
"margin-bottom: 50px;
"
>
<fieldset>
<legend>
{% trans "
Language selection
" %}
</legend>
<legend>
{% trans "
My preferences
" %}
</legend>
{% crispy forms.change_language %}
</fieldset>
</div>
<div
class=
"col-md-4"
>
<fieldset>
<legend>
{% trans "Current avatar" %}
</legend>
<p>
<img
id=
"dashboard-profile-avatar"
class=
"img-rounded"
src=
"{{ object.get_avatar_url }}"
/>
</p>
<p>
<a
href=
"{% url "
dashboard
.
views
.
profile
"
username=
profile.user.username
%}"
>
{% trans "Go to my profile" %}
</a>
</p>
</fieldset>
</div>
</div>
</div>
</div>
...
...
circle/dashboard/views.py
View file @
c1cb2807
...
...
@@ -22,7 +22,6 @@ from os import getenv
import
json
import
logging
import
re
from
hashlib
import
md5
import
requests
from
django.conf
import
settings
...
...
@@ -47,7 +46,6 @@ from django.utils.translation import ugettext as _
from
django.utils.translation
import
ungettext
as
__
from
django.template.loader
import
render_to_string
from
django.template
import
RequestContext
from
django.templatetags.static
import
static
from
django.forms.models
import
inlineformset_factory
from
django_tables2
import
SingleTableView
...
...
@@ -2818,7 +2816,7 @@ class ProfileView(LoginRequiredMixin, DetailView):
context
=
super
(
ProfileView
,
self
)
.
get_context_data
(
**
kwargs
)
user
=
self
.
get_object
()
context
[
'profile'
]
=
user
context
[
'avatar_url'
]
=
get_user_avatar_url
(
user
)
context
[
'avatar_url'
]
=
user
.
profile
.
get_avatar_url
(
)
context
[
'instances_owned'
]
=
Instance
.
get_objects_with_level
(
"owner"
,
user
,
disregard_superuser
=
True
)
.
filter
(
destroyed_at
=
None
)
context
[
'instances_with_access'
]
=
Instance
.
get_objects_with_level
(
...
...
@@ -2862,16 +2860,8 @@ def toggle_use_gravatar(request, **kwargs):
profile
.
use_gravatar
=
not
profile
.
use_gravatar
profile
.
save
()
new_avatar_url
=
get_user_avatar_url
(
user
)
new_avatar_url
=
user
.
profile
.
get_avatar_url
(
)
return
HttpResponse
(
json
.
dumps
({
'new_avatar_url'
:
new_avatar_url
}),
content_type
=
"application/json"
,
)
def
get_user_avatar_url
(
user
):
if
user
.
profile
.
use_gravatar
:
gravatar_hash
=
md5
(
user
.
email
)
.
hexdigest
()
return
"https://secure.gravatar.com/avatar/
%
s?s=200"
%
gravatar_hash
else
:
return
static
(
"dashboard/img/avatar.png"
)
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