membershipworks: Clean up Event admin change view

This commit is contained in:
Adam Goldsmith 2024-08-28 16:48:50 -04:00
parent e34ccbfb48
commit c356913a8b

View File

@ -178,11 +178,52 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
show_facets = admin.ShowFacets.ALWAYS show_facets = admin.ShowFacets.ALWAYS
search_fields = ["eid", "title", "url"] search_fields = ["eid", "title", "url"]
date_hierarchy = "start" date_hierarchy = "start"
exclude = ["url", "details", "registrations"]
autocomplete_fields = ["instructor"] autocomplete_fields = ["instructor"]
change_actions = ["fetch_details"] change_actions = ["fetch_details"]
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]: def get_readonly_fields(self, request: HttpRequest, obj: EventExt) -> list[str]:
fields = [] fields = []
for field in Event._meta.get_fields(): for field in Event._meta.get_fields():
@ -193,7 +234,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
else: else:
fields.append(field.name) fields.append(field.name)
fields.insert(fields.index("end") + 1, "duration") fields.insert(fields.index("end") + 1, "duration")
fields.append("details_timestamp") fields += ["details_timestamp", "details", "registrations"]
return fields return fields
@admin.display(ordering="title") @admin.display(ordering="title")