Adam Goldsmith
7f7c6484ea
Retroactively adding to the initial migration as this table already existed, just wasn't represented in the Django app yet
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
from django.contrib import admin
|
|
|
|
from .models import Member, Flag, Transaction
|
|
|
|
|
|
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"]
|
|
|
|
|
|
@admin.register(Transaction)
|
|
class TransactionAdmin(ReadOnlyAdmin):
|
|
list_display = ["timestamp", "member", "name", "type", "sum", "note"]
|
|
list_filter = ["type"]
|
|
show_facets = admin.ShowFacets.ALWAYS
|