From d9ae263da062ad37e12f268bf8d15b8249fadf03 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 20 Dec 2024 23:35:27 -0500 Subject: [PATCH] membershipworks: Add refresh data button for event details page Closes #56 --- .../templates/membershipworks/event_detail.dj.html | 14 ++++++++++---- membershipworks/views.py | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/membershipworks/templates/membershipworks/event_detail.dj.html b/membershipworks/templates/membershipworks/event_detail.dj.html index 69f35b5..ebbfe36 100644 --- a/membershipworks/templates/membershipworks/event_detail.dj.html +++ b/membershipworks/templates/membershipworks/event_detail.dj.html @@ -13,10 +13,16 @@ {% endblock %} {% block content %}
- {% if event.registrations is not None %} - {% url 'membershipworks:event-registrations' event.pk as registrations_url %} - {% bootstrap_button href=registrations_url content="Show Registrations" %} - {% endif %} +
+
+ {% if event.registrations is not None %} + {% url 'membershipworks:event-registrations' event.pk as registrations_url %} + {% bootstrap_button extra_classes="btn-sm" href=registrations_url content="Show Registrations" %} + {% endif %} +
+
{% include "membershipworks/components/refresh_data_button.dj.html" %}
+
+ {% include "membershipworks/event_invoice.dj.html" %}
diff --git a/membershipworks/views.py b/membershipworks/views.py index 571a166..32a71a7 100644 --- a/membershipworks/views.py +++ b/membershipworks/views.py @@ -41,7 +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 membershipworks.tasks.scrape import scrape_event_details, scrape_events from .forms import EventInvoiceForm from .invoice_email import make_invoice_emails @@ -311,6 +311,10 @@ class EventDetailView( if self.request.user.has_perm( self.permission_required ) or self.object.user_is_instructor(self.request.user): + if "refresh" in self.request.GET: + scrape_events() + scrape_event_details([self.object]) + return super().render_to_response(context, **response_kwargs) else: return self.handle_no_permission()