cmsmanage/membershipworks/admin.py
Adam Goldsmith e03b9e3c70 Always show admin facet counts in most models with filters
New feature in Django 5.0

Didn't enable always on HIDEvent admin, as the table size is relatively large
2023-12-04 13:09:13 -05:00

34 lines
801 B
Python

from django.contrib import admin
from .models import Member, Flag
class ReadOnlyAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
return False
class MemberFlagInline(admin.TabularInline):
model = Member.flags.through
@admin.register(Member)
class MemberAdmin(ReadOnlyAdmin):
search_fields = ["^first_name", "^last_name", "^account_name"]
inlines = [MemberFlagInline]
@admin.register(Flag)
class FlagAdmin(ReadOnlyAdmin):
inlines = [MemberFlagInline]
list_display = ["name", "type"]
list_filter = ["type"]
show_facets = admin.ShowFacets.ALWAYS
search_fields = ["name"]