Extend members app: add fields to Member model, update migrations, and configure admin display

This commit is contained in:
2026-01-04 22:42:54 +01:00
parent a38a813865
commit 769f18dac8
8 changed files with 169 additions and 3 deletions

View File

@@ -1,3 +1,28 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
# Register your models here.
from .models import Member
@admin.register(Member)
class MemberAdmin(admin.ModelAdmin):
def family_member_count(self, obj):
return obj.family_members.count()
def show_user_is_active(self, obj):
return obj.user.is_active
show_user_is_active.boolean = True
show_user_is_active.short_description = _("active?")
list_display = ["__str__", "user__email", "show_user_is_active", "family_member_count", "birthday", "created", "updated"]
date_hierarchy = "birthday"
list_filter = ["user__is_superuser", "user__is_active"]
readonly_fields = ["created", "updated", "access_token"]
filter_horizontal = ["family_members"]
raw_id_fields = ["user"]
fieldsets = [
("GENERAL INFORMATION", {"fields": ["user", "family_members", "birthday", "license", "access_token"]}),
("CONTACT_INFORMATION", {"fields": ["phone_number", "emergency_phone_number"]}),
("METADATA", {"fields": ["created", "updated"]}),
]