diff options
author | Pavlos Ratis <dastergon@gentoo.org> | 2013-09-24 23:43:30 +0300 |
---|---|---|
committer | Pavlos Ratis <dastergon@gentoo.org> | 2013-09-24 23:43:30 +0300 |
commit | ecf411a02216891ae473768c05a0a5c79d7fa2d7 (patch) | |
tree | 02c070fb415fdd97ad54b5e98ef66d39be8bbf80 | |
parent | Merge pull request #101 from dastergon/final_fixes (diff) | |
download | identity.gentoo.org-ecf411a02216891ae473768c05a0a5c79d7fa2d7.tar.gz identity.gentoo.org-ecf411a02216891ae473768c05a0a5c79d7fa2d7.tar.bz2 identity.gentoo.org-ecf411a02216891ae473768c05a0a5c79d7fa2d7.zip |
add Gravatar support
-rw-r--r-- | okupy/accounts/forms.py | 3 | ||||
-rw-r--r-- | okupy/accounts/models.py | 1 | ||||
-rw-r--r-- | okupy/accounts/views.py | 6 | ||||
-rw-r--r-- | okupy/templates/index.html | 5 | ||||
-rw-r--r-- | okupy/templates/settings-email.html | 14 |
5 files changed, 28 insertions, 1 deletions
diff --git a/okupy/accounts/forms.py b/okupy/accounts/forms.py index 47b66a2..d26c34b 100644 --- a/okupy/accounts/forms.py +++ b/okupy/accounts/forms.py @@ -105,7 +105,8 @@ class EmailSettingsForm(forms.Form): email = forms.EmailField(max_length=254, label='Add Email', help_text='A valid email address, please.', required=False) - + gravatar = forms.EmailField(max_length=254, label='Gravatar Email', + required=False) class ContactSettingsForm(forms.Form): website = forms.URLField(label='Website', required=False) diff --git a/okupy/accounts/models.py b/okupy/accounts/models.py index 4da7ee4..239c99f 100644 --- a/okupy/accounts/models.py +++ b/okupy/accounts/models.py @@ -51,6 +51,7 @@ class LDAPUser(ldapdb.models.Model): gentoo_retire_date = ListField(db_column='gentooRetire') gpg_fingerprint = ListField(db_column='gpgfingerprint') gpg_key = ListField(db_column='gpgKey') + gravatar = CharField(db_column='gravatar') im = ListField(db_column='gentooIM') latitude = FloatField(db_column='lat') location = CharField(db_column='gentooLocation') diff --git a/okupy/accounts/views.py b/okupy/accounts/views.py index febe39b..6487c8b 100644 --- a/okupy/accounts/views.py +++ b/okupy/accounts/views.py @@ -49,6 +49,7 @@ from okupy.otp.totp.models import TOTPDevice import openid.yadis.discover import openid.fetchers import django_otp +import hashlib import io import ldap import logging @@ -481,12 +482,17 @@ def email_settings(request): if email_settings.is_valid(): try: email = email_settings.cleaned_data['email'] + gravatar_mail = email_settings.cleaned_data['gravatar'] if request.POST.get('delete'): user_info.email.remove(email) else: user_info.email.append(email) + if gravatar_mail: + gravatar_hash = hashlib.md5(gravatar_mail).hexdigest() + user_info.gravatar = gravatar_hash + try: user_info.save() except IntegrityError: diff --git a/okupy/templates/index.html b/okupy/templates/index.html index 5c3e2de..f464d46 100644 --- a/okupy/templates/index.html +++ b/okupy/templates/index.html @@ -16,6 +16,11 @@ </table> </div> </p> + {% if user.gravatar %} + <div class="span2"> + <img class="thumbnail" src="https://gravatar.com/avatar/{{ user.gravatar }}?d=identicons&s=200" alt="" /> + </div> + {% endif %} </div> <div class="row-fluid"> <p> diff --git a/okupy/templates/settings-email.html b/okupy/templates/settings-email.html index 51a5eba..1c21f28 100644 --- a/okupy/templates/settings-email.html +++ b/okupy/templates/settings-email.html @@ -36,6 +36,20 @@ <input class="btn btn-primary" type="submit" value="Add email" /> </div> </form> + <div>Current avatar:<br /> + {% if user_info.gravatar %} + <img class="thumbnail" src="https://gravatar.com/avatar/{{ user_info.gravatar }}?d=identicons&s=170" /> + {% else %} + No avatar + {% endif %} + </div><br /> + <form action="." method="POST">{% csrf_token %} + {{ email_settings.gravatar.label_tag }} + {{ email_settings.gravatar }} {{ email_settings.gravatar.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Submit" /> + </div> + </form> </div> </div> </div> |