2022-02-03 13:45:58 -05:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2023-12-19 23:42:46 -05:00
|
|
|
from .models import Member, Flag, Transaction
|
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"]
|
2023-12-04 13:08:36 -05:00
|
|
|
show_facets = admin.ShowFacets.ALWAYS
|
2023-01-19 19:02:03 -05:00
|
|
|
search_fields = ["name"]
|
2023-12-19 23:42:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Transaction)
|
|
|
|
class TransactionAdmin(ReadOnlyAdmin):
|
|
|
|
list_display = ["timestamp", "member", "name", "type", "sum", "note"]
|
|
|
|
list_filter = ["type"]
|
|
|
|
show_facets = admin.ShowFacets.ALWAYS
|