Adds gravatars and firstnames
This commit is contained in:
1 parent
c05e8f9aa4
commit
85071ba6af
6 files changed
+15
-63
No files matched your search
+1
-1
@@ -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
|
||||
|
||||
+3
-54
@@ -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'
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 %}
|
||||
<img class="profile" src="{{ user.get_profile.image.url }}" /><br />
|
||||
{% else %}
|
||||
<img class="profile" src="{{ STATIC_URL }}gaute/img/unknown.png" /><br />
|
||||
<img class="profile" src="{% gravatar_for_user user %}" /><br />
|
||||
{% endif %}
|
||||
<span class="name">{{ user }}</span> ({{ user.get_profile.balance }})
|
||||
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span> ({{ user.get_profile.balance }})
|
||||
<span class="id" style="display:none;">{{ user.id }}</span>
|
||||
</li>
|
||||
</li>
|
||||
|
||||
@@ -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 %}
|
||||
<img class="profile" src="{{ user.get_profile.image.url }}" /><br />
|
||||
{% else %}
|
||||
<img class="profile" src="{{ STATIC_URL }}gaute/img/unknown.png" /><br />
|
||||
<img class="profile" src="{% gravatar_for_user user %}" /><br />
|
||||
{% endif %}
|
||||
<span class="name">{{ user }}</span> ({{ user.get_profile.balance }})
|
||||
<span class="name">{{ user.first_name }} {{ user.last_name|slice:":1"}}</span> ({{ user.get_profile.balance }})
|
||||
<span class="username" style="display:none;">{{ user }}</span>
|
||||
<span class="id" style="display:none;">{{ user.id }}</span>
|
||||
</li>
|
||||
</li>
|
||||
|
||||
Reference in new issue
Block a user