1
2
3
4 from django.utils.safestring import mark_safe
5 from django.contrib.auth.models import User, Group
6 from django.contrib.auth.admin import UserAdmin, GroupAdmin
7 from django.contrib import admin
8
10
11 p = sorted([u"<a title='%s'>%s</a>" % (x, x) for x in self.groups.all()])
12 if self.user_permissions.count():
13 p += ['+']
14 value = ' | '.join(p)
15 return mark_safe("%s" % value)
16 roles.allow_tags = True
17 roles.short_description = u'Groups'
18
20 fmt = "%b %d, %H:%M"
21
22 value = self.last_login.strftime(fmt)
23 return mark_safe("<nobr>%s</nobr>" % value)
24 last.allow_tags = True
25 last.admin_order_field = 'last_login'
26
28 return self.is_superuser
29 adm.boolean = True
30 adm.admin_order_field = 'is_superuser'
31
34 staff.boolean = True
35 staff.admin_order_field = 'is_staff'
36
37 from django.core.urlresolvers import reverse
39 return ', '.join(['<a href="%s">%s</a>' % (reverse('admin:auth_user_change', args=(x.id,)), x.username) for x in self.user_set.all().order_by('username')])
40 persons.allow_tags = True
41
47
57 allow_share_to_staff.short_description = "Allow selected users to share to staff for review"
58
63 remove_users_from_all_groups.short_description = "Remove all group associations from selected users"
64
66 list_display = ['username', 'email', 'first_name', 'last_name', 'is_active', staff, adm, roles, last]
67 list_filter = ['groups', 'is_staff', 'is_superuser', 'is_active']
68 actions = [allow_share_to_staff, remove_users_from_all_groups]
69
74
75 admin.site.unregister(User)
76 admin.site.unregister(Group)
77 admin.site.register(User, UserAdmin)
78 admin.site.register(Group, GroupAdmin)
79