membershipworks: Add refresh action in EventAdmin

This commit is contained in:
Adam Goldsmith 2024-08-28 17:07:27 -04:00
parent c356913a8b
commit 0cd88c00f1

View File

@ -22,7 +22,7 @@ from .models import (
Member, Member,
Transaction, Transaction,
) )
from .tasks.scrape import scrape_event_details, scrape_membershipworks from .tasks.scrape import scrape_event_details, scrape_events, scrape_membershipworks
from .tasks.ucsAccounts import sync_accounts from .tasks.ucsAccounts import sync_accounts
@ -181,6 +181,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
autocomplete_fields = ["instructor"] autocomplete_fields = ["instructor"]
change_actions = ["fetch_details"] change_actions = ["fetch_details"]
actions = ["fetch_details"] actions = ["fetch_details"]
changelist_actions = ["refresh_membershipworks_data"]
fieldsets = [ fieldsets = [
( (
@ -224,6 +225,10 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
), ),
] ]
@property
def refresh_membershipworks_data(self):
return run_task_action(self, "Refresh Data", scrape_events)
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():