From 85071ba6af6b842122726eb01752746da10b752c Mon Sep 17 00:00:00 2001 From: Nikolai Kristiansen Date: Thu, 23 Feb 2012 03:28:52 +0100 Subject: [PATCH] Adds gravatars and firstnames --- main/views.py | 2 +- settings-sample.py | 57 +++-------------------------------------- static/js/deposit.js | 4 +-- static/js/register.js | 4 +-- templates/deposit.html | 5 ++-- templates/register.html | 6 +++-- 6 files changed, 15 insertions(+), 63 deletions(-) diff --git a/main/views.py b/main/views.py index 987f690..1102785 100755 --- a/main/views.py +++ b/main/views.py @@ -110,6 +110,6 @@ def logout(request): def users_format_js(users): users = "[{0}]".format( - ",".join(['"'+user+'"' for user in users.values_list('username', flat=True)])) + ",".join(['"'+user[0]+ ' ' + user[1][:1] + '"' for user in users.values_list('first_name','last_name')])) return users diff --git a/settings-sample.py b/settings-sample.py index a0afe30..05220ca 100755 --- a/settings-sample.py +++ b/settings-sample.py @@ -124,7 +124,7 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.admin', 'main', - # 'django.contrib.admindocs', + 'gravatar', ) # A sample logging configuration. The only tangible logging @@ -153,56 +153,5 @@ LOGGING = { # User profile AUTH_PROFILE_MODULE = 'main.UserProfile' -AUTHENTICATION_BACKENDS = ( - 'django_auth_ldap.backend.LDAPBackend', - 'django.contrib.auth.backends.ModelBackend', -) - -# LDAP server URI and BIND_DN, same as db-settings -AUTH_LDAP_SERVER_URI = '' -AUTH_LDAP_BIND_DN = '' -AUTH_LDAP_BIND_PASSWORD = '' - -import ldap -from django_auth_ldap.config import LDAPSearch, PosixGroupType - -# Basic user auth -AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=People,dc=neuf,dc=no", - ldap.SCOPE_ONELEVEL, "(uid=%(user)s)") -AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=People,dc=neuf,dc=no" -# Basic groups -AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=Groups,dc=neuf,dc=no", - ldap.SCOPE_ONELEVEL, "(objectClass=posixGroup)" -) -AUTH_LDAP_GROUP_TYPE = PosixGroupType() -# Mirror groups on each auth -AUTH_LDAP_MIRROR_GROUPS = True -# Group to user flag mappings -AUTH_LDAP_USER_FLAGS_BY_GROUP = { - "is_active": "cn=dns-alle,ou=Groups,dc=neuf,dc=no", - "is_staff": "cn=edb,ou=Groups,dc=neuf,dc=no", - "is_superuser": "cn=edbadmin,ou=Groups,dc=neuf,dc=no" -} -# Group to profile flag mappings, not used. -AUTH_LDAP_PROFILE_FLAGS_BY_GROUP = { - #"is_edb": "cn=edb,ou=Groups,dc=neuf,dc=no" -} -# User attribute mappings -AUTH_LDAP_USER_ATTR_MAP = { - "first_name": "givenName", - "last_name": "sn", - "email": "mail", -} -# User profile attribute mappings -AUTH_LDAP_PROFILE_ATTR_MAP = { - "home_directory": "homeDirectory" -} -# Allways update the django user object on authentication. -AUTH_LDAP_ALWAYS_UPDATE_USER = True - -# Debug logging -import logging -logger = logging.getLogger('django_auth_ldap') -logger.addHandler(logging.StreamHandler()) -logger.setLevel(logging.DEBUG) - +# Gravatar +GRAVATAR_DEFAULT_IMAGE = 'mm' diff --git a/static/js/deposit.js b/static/js/deposit.js index 8721d9e..882b60e 100644 --- a/static/js/deposit.js +++ b/static/js/deposit.js @@ -33,8 +33,8 @@ $(document).ready(function() { /* Disable the customer button just clicked */ $(this).addClass("marked"); /* Update the typeahead field */ - var username = $(this).children("span.name").text() - $("#id_customer_typeahead").val(username); + var name = $(this).children("span.name").text() + $("#id_customer_typeahead").val(name); /* Update the select field */ var id = $(this).children("span.id").text() $("#id_user option").removeAttr('selected'); diff --git a/static/js/register.js b/static/js/register.js index a823381..ba1fbe0 100644 --- a/static/js/register.js +++ b/static/js/register.js @@ -33,8 +33,8 @@ $(document).ready(function() { /* Disable the customer button just clicked */ $(this).addClass("marked"); /* Update the typeahead field */ - var username = $(this).children("span.name").text() - $("#id_customer_typeahead").val(username); + var name = $(this).children("span.name").text() + $("#id_customer_typeahead").val(name); /* Update the select field */ var id = $(this).children("span.id").text() $("#id_customer option").removeAttr('selected'); diff --git a/templates/deposit.html b/templates/deposit.html index 631d79a..c95fd7c 100644 --- a/templates/deposit.html +++ b/templates/deposit.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load gravatar %} {% block header %} {% include "nav.html" with active="deposit" %} {% endblock %} @@ -29,9 +30,9 @@ {% if user.get_profile.image %}  
{% else %} -  
+  
{% endif %} - {{ user }} ({{ user.get_profile.balance }}) + {{ user.first_name }} {{ user.last_name|slice:":1"}} ({{ user.get_profile.balance }}) diff --git a/templates/register.html b/templates/register.html index adf8b8f..48074cc 100644 --- a/templates/register.html +++ b/templates/register.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load gravatar %} {% block header %} {% include "nav.html" with active="register" %} {% endblock %} @@ -36,9 +37,10 @@ {% if user.get_profile.image %}  
{% else %} -  
+  
{% endif %} - {{ user }} ({{ user.get_profile.balance }}) + {{ user.first_name }} {{ user.last_name|slice:":1"}} ({{ user.get_profile.balance }}) +