From c356913a8b1411923525d95cb69c71b297faed65 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 28 Aug 2024 16:48:50 -0400 Subject: [PATCH] membershipworks: Clean up Event admin change view --- membershipworks/admin.py | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/membershipworks/admin.py b/membershipworks/admin.py index 85a0e30..45ffb17 100644 --- a/membershipworks/admin.py +++ b/membershipworks/admin.py @@ -178,11 +178,52 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin): show_facets = admin.ShowFacets.ALWAYS search_fields = ["eid", "title", "url"] date_hierarchy = "start" - exclude = ["url", "details", "registrations"] autocomplete_fields = ["instructor"] change_actions = ["fetch_details"] actions = ["fetch_details"] + fieldsets = [ + ( + None, + { + "fields": [ + "instructor", + "materials_fee", + "materials_fee_included_in_price", + "instructor_percentage", + "instructor_flat_rate", + ("should_survey", "survey_email_sent"), + ] + }, + ), + ( + "Details", + { + "classes": ["collapse"], + "fields": [ + "eid", + "_url", + "start", + "end", + "duration", + "count", + "cap", + "category", + "calendar", + "venue", + "occurred", + ], + }, + ), + ( + "Advanced details", + { + "classes": ["collapse"], + "fields": ["details_timestamp", "details", "registrations"], + }, + ), + ] + def get_readonly_fields(self, request: HttpRequest, obj: EventExt) -> list[str]: fields = [] for field in Event._meta.get_fields(): @@ -193,7 +234,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin): else: fields.append(field.name) fields.insert(fields.index("end") + 1, "duration") - fields.append("details_timestamp") + fields += ["details_timestamp", "details", "registrations"] return fields @admin.display(ordering="title")