123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- from django.utils.translation import gettext_lazy as _
- from django.contrib import admin
- from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
- from access.models import User
- from django.contrib.auth.models import Group
- admin.site.unregister(Group)
- @admin.register(User)
- class UserAdmin(BaseUserAdmin):
- search_fields = ["email", "name"]
- readonly_fields = ["id", "uuid", "created_at", "updated_at"]
- list_display = [
- "email",
- "name",
- "gender",
- "birthdate",
- "avatar",
- "is_active",
- "is_admin",
- "is_staff",
- "created_at",
- ]
- list_filter = [
- "is_active",
- "is_admin",
- "is_staff",
- "created_at",
- "updated_at",
- "gender",
- ]
- filter_horizontal = []
- date_hierarchy = "created_at"
- ordering = ["-created_at"]
- add_fieldsets = (
- (
- _("Сведения"),
- {
- "fields": ["name", "email", "birthdate", "gender", "avatar"]
- },
- ),
- (
- _("Доступ"),
- {"fields": ["is_active", "is_admin", "is_staff"]},
- ),
- )
- fieldsets = (
- (
- _("Сведения"),
- {
- "fields": ["id", "uuid", "name", "email", "birthdate", "gender", "avatar"]
- },
- ),
- (
- _("Доступ"),
- {"fields": ["is_active", "is_admin","is_staff", "password"]},
- ),
- (_("Даты"), {"fields": ["created_at", "updated_at"]}),
- )
- class Media:
- pass
|