2022-02-03 13:45:58 -05:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2022-02-10 16:51:32 -05:00
|
|
|
from .models import Member, Flag
|
2022-02-03 13:45:58 -05:00
|
|
|
|
|
|
|
|
2022-02-10 16:51:32 -05:00
|
|
|
class ReadOnlyAdmin(admin.ModelAdmin):
|
2022-02-03 13:45:58 -05:00
|
|
|
def has_add_permission(self, request, obj=None):
|
|
|
|
return False
|
|
|
|
|
2022-02-10 16:51:32 -05:00
|
|
|
def has_change_permission(self, request, obj=None):
|
|
|
|
return False
|
|
|
|
|
2022-02-03 13:45:58 -05:00
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
|
|
return False
|
2022-02-10 16:51:32 -05:00
|
|
|
|
|
|
|
|
|
|
|
class MemberFlagInline(admin.TabularInline):
|
|
|
|
model = Member.flags.through
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Member)
|
|
|
|
class MemberAdmin(ReadOnlyAdmin):
|
2023-03-31 23:54:16 -04:00
|
|
|
search_fields = ["^first_name", "^last_name", "^account_name"]
|
2022-02-10 16:51:32 -05:00
|
|
|
inlines = [MemberFlagInline]
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Flag)
|
|
|
|
class FlagAdmin(ReadOnlyAdmin):
|
|
|
|
inlines = [MemberFlagInline]
|
2023-01-19 19:02:03 -05:00
|
|
|
list_display = ["name", "type"]
|
|
|
|
list_filter = ["type"]
|
|
|
|
search_fields = ["name"]
|