gestiojeux/accounts/admin.py
Guillaume Bertholon c836f642fa Authenticate by email with a custom user model
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.
2020-12-24 14:19:35 +01:00

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)