Skip to content

Commit

Permalink
Django admin improvements. (#2907)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadhg-ohiggins authored Nov 30, 2023
1 parent f698ca8 commit de7c759
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/audit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@


class SACAdmin(admin.ModelAdmin):
"""
Support for read-only staff access, and control of what fields are present and
filterable/searchable.
"""

def has_module_permission(self, request, obj=None):
return request.user.is_staff

Expand All @@ -21,6 +26,7 @@ def has_view_permission(self, request, obj=None):
"oversight_agency",
]
readonly_fields = ("submitted_by",)
search_fields = ("general_information__auditee_uei", "report_id")


class AccessAdmin(admin.ModelAdmin):
Expand All @@ -29,9 +35,16 @@ class AccessAdmin(admin.ModelAdmin):
it's redundant with email in almost all circumstances.
"""

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = ("sac", "role", "email")
list_filter = ["role"]
readonly_fields = ("sac",)
search_fields = ("email", "sac__report_id")


class ExcelFileAdmin(admin.ModelAdmin):
Expand Down

0 comments on commit de7c759

Please sign in to comment.