membershipworks: Add "Refresh Data" button to event registrations view
This commit is contained in:
parent
611dd6ea0b
commit
7108f9418d
@ -4,7 +4,6 @@ from datetime import datetime, timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
from django.db.models import QuerySet
|
||||
|
||||
from cmsmanage.django_q2_helper import q_task_group
|
||||
from membershipworks.membershipworks_api import FieldType, MembershipWorks
|
||||
@ -125,13 +124,13 @@ def scrape_membershipworks(*args, **options):
|
||||
scrape_transactions(membershipworks)
|
||||
|
||||
|
||||
def scrape_event_details(queryset: QuerySet[EventExt]):
|
||||
def scrape_event_details(events: Iterable[EventExt]):
|
||||
membershipworks = MembershipWorks()
|
||||
membershipworks.login(
|
||||
settings.MEMBERSHIPWORKS_USERNAME, settings.MEMBERSHIPWORKS_PASSWORD
|
||||
)
|
||||
|
||||
for event in queryset:
|
||||
for event in events:
|
||||
event.details = membershipworks.get_event_by_eid(event.eid)
|
||||
event.registrations = membershipworks.get_event_registrations(event.eid)
|
||||
event.save()
|
||||
|
@ -22,6 +22,18 @@
|
||||
{% bootstrap_button extra_classes="btn-sm" href=email_link target="_blank" content="Email all attendees" %}
|
||||
</div>
|
||||
<div class="col-auto">{% include "cmsmanage/components/download_table.dj.html" %}</div>
|
||||
<div class="col-auto">
|
||||
<a class="btn btn-sm btn-primary"
|
||||
hx-boost="true"
|
||||
hx-push-url="false"
|
||||
hx-indicator=".htmx-indicator"
|
||||
href="{% querystring refresh=1 %}">
|
||||
<div class="spinner-border spinner-border-sm htmx-indicator" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
Refresh Data
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="d-none d-print-block">Registrations for {{ event.details.ttl|nh3 }}</h2>
|
||||
{% render_table table %}
|
||||
|
@ -41,6 +41,7 @@ from django_weasyprint import WeasyTemplateResponseMixin
|
||||
from django_weasyprint.utils import django_url_fetcher
|
||||
|
||||
from membershipworks.membershipworks_api import MembershipWorks
|
||||
from membershipworks.tasks.scrape import scrape_event_details
|
||||
|
||||
from .forms import EventInvoiceForm
|
||||
from .invoice_email import make_invoice_emails
|
||||
@ -453,6 +454,9 @@ class EventRegistrationsView(ExportMixin, SingleTableMixin, AccessMixin, DetailV
|
||||
def render_to_response(
|
||||
self, context: dict[str, Any], **response_kwargs: Any
|
||||
) -> HttpResponse:
|
||||
if "refresh" in self.request.GET:
|
||||
scrape_event_details([self.object])
|
||||
|
||||
if self.request.user.has_perm(
|
||||
self.permission_required
|
||||
) or self.object.user_is_instructor(self.request.user):
|
||||
|
Loading…
x
Reference in New Issue
Block a user