From 7fd9181da1c8c7feafeef02ead8db4332231d60a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 8 Feb 2024 15:45:02 -0500 Subject: [PATCH] membershipworks: Add changelist action to sync UCS accounts --- membershipworks/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/membershipworks/admin.py b/membershipworks/admin.py index 7514f8b..54ad54c 100644 --- a/membershipworks/admin.py +++ b/membershipworks/admin.py @@ -23,6 +23,7 @@ from .tasks.scrape import ( scrape_event_details, scrape_membershipworks, ) +from .tasks.ucsAccounts import sync_accounts class ReadOnlyAdmin(admin.ModelAdmin): @@ -37,7 +38,7 @@ class ReadOnlyAdmin(admin.ModelAdmin): class BaseMembershipWorksAdmin(DjangoObjectActions, ReadOnlyAdmin): - changelist_actions = ("refresh_membershipworks_data",) + changelist_actions = ("refresh_membershipworks_data", "sync_ucs_accounts") # internal method from DjangoObjectActions def _get_tool_dict(self, tool_name): @@ -62,6 +63,14 @@ class BaseMembershipWorksAdmin(DjangoObjectActions, ReadOnlyAdmin): "Queued refresh, please wait a few seconds/minutes then refresh the page", ) + @action + def sync_ucs_accounts(self, request, obj): + async_task(sync_accounts, group=sync_accounts.q_task_group) + self.message_user( + request, + "Queued refresh, please wait a few seconds/minutes then refresh the page", + ) + class MemberFlagInline(admin.TabularInline): model = Member.flags.through