Add changes to admin

This commit is contained in:
Erin 2024-04-16 11:17:11 -07:00
parent 12526c13f7
commit aa14281338
No known key found for this signature in database
GPG key ID: 1CAD275313C62460

View file

@ -497,8 +497,8 @@ class MyUserAdmin(BaseUserAdmin):
# Renames inherited AbstractUser label 'email_address to 'email' # Renames inherited AbstractUser label 'email_address to 'email'
def formfield_for_dbfield(self, dbfield, **kwargs): def formfield_for_dbfield(self, dbfield, **kwargs):
field = super().formfield_for_dbfield(dbfield, **kwargs) field = super().formfield_for_dbfield(dbfield, **kwargs)
if dbfield.name == 'email': if dbfield.name == "email":
field.label = 'Email' field.label = "Email"
return field return field
# Renames inherited AbstractUser column name 'email_address to 'email' # Renames inherited AbstractUser column name 'email_address to 'email'
@ -2036,19 +2036,15 @@ class FederalAgencyAdmin(ListHeaderAdmin):
class UserGroupAdmin(AuditedAdmin): class UserGroupAdmin(AuditedAdmin):
"""Overwrite the generated UserGroup admin class""" """Overwrite the generated UserGroup admin class"""
list_display = [ list_display = ["user_group"]
"user_group"
]
fieldsets = ( fieldsets = ((None, {"fields": ("name", "permissions")}),)
(None, {'fields': ('name', 'permissions')}),
)
def formfield_for_dbfield(self, dbfield, **kwargs): def formfield_for_dbfield(self, dbfield, **kwargs):
field = super().formfield_for_dbfield(dbfield, **kwargs) field = super().formfield_for_dbfield(dbfield, **kwargs)
if dbfield.name == 'name': if dbfield.name == "name":
field.label = 'Group name' field.label = "Group name"
if dbfield.name == 'permissions': if dbfield.name == "permissions":
field.label = "User permissions" field.label = "User permissions"
return field return field
@ -2059,6 +2055,7 @@ class UserGroupAdmin(AuditedAdmin):
def user_group(self, obj): def user_group(self, obj):
return obj.name return obj.name
admin.site.unregister(LogEntry) # Unregister the default registration admin.site.unregister(LogEntry) # Unregister the default registration
admin.site.register(LogEntry, CustomLogEntryAdmin) admin.site.register(LogEntry, CustomLogEntryAdmin)
admin.site.register(models.User, MyUserAdmin) admin.site.register(models.User, MyUserAdmin)