c836f642fa
This avoid the weird double username situation where we want to give the users the choice of their displayed name but at the same time we need them to never change their CAS username. Now CAS matches on email so we do not have problems.
38 lines
1 KiB
Python
38 lines
1 KiB
Python
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
|
|
from django.utils.translation import gettext_lazy as _
|
|
from .models import User
|
|
|
|
|
|
class UserAdmin(DjangoUserAdmin):
|
|
fieldsets = (
|
|
(None, {"fields": ("email", "password")}),
|
|
(_("Personal info"), {"fields": ("public_name",)}),
|
|
(
|
|
_("Permissions"),
|
|
{
|
|
"fields": (
|
|
"is_active",
|
|
"is_staff",
|
|
"is_superuser",
|
|
"groups",
|
|
"user_permissions",
|
|
),
|
|
},
|
|
),
|
|
)
|
|
add_fieldsets = (
|
|
(
|
|
None,
|
|
{
|
|
"classes": ("wide",),
|
|
"fields": ("email", "public_name", "password1", "password2"),
|
|
},
|
|
),
|
|
)
|
|
list_display = ("public_name", "email", "is_staff")
|
|
search_fields = ("public_name", "email")
|
|
ordering = ("email",)
|
|
|
|
|
|
admin.site.register(User, UserAdmin)
|