Compare commits

...

4 Commits

Author SHA1 Message Date
71d2227854 doorcontrol: Treat members in "Misc. Access" folder as active for Access
All checks were successful
Ruff / ruff (push) Successful in 51s
Test / test (push) Successful in 6m4s
2024-12-24 10:36:03 -05:00
d9ae263da0 membershipworks: Add refresh data button for event details page
All checks were successful
Ruff / ruff (push) Successful in 31s
Test / test (push) Successful in 5m48s
Closes #56
2024-12-20 23:36:11 -05:00
1e09ebf24b membershipworks: Move refresh data button into a separate component file 2024-12-20 16:35:23 -05:00
7108f9418d membershipworks: Add "Refresh Data" button to event registrations view
All checks were successful
Ruff / ruff (push) Successful in 42s
Test / test (push) Successful in 6m10s
2024-12-20 16:30:00 -05:00
6 changed files with 37 additions and 8 deletions

View File

@ -149,7 +149,12 @@ def sync_members(access_client: AccessClient):
if access_user := access_users_by_employee_number.get(member.uid): if access_user := access_users_by_employee_number.get(member.uid):
expected_user["status"] = ( expected_user["status"] = (
UserStatus.ACTIVE if member.is_active else UserStatus.DEACTIVATED UserStatus.ACTIVE
if (
member.is_active
or member.flags.filter(name="Misc. Access", type="folder").exists()
)
else UserStatus.DEACTIVATED
) )
changes = { changes = {
k: v for k, v in expected_user.items() if getattr(access_user, k) != v k: v for k, v in expected_user.items() if getattr(access_user, k) != v

View File

@ -4,7 +4,6 @@ from datetime import datetime, timedelta
from django.conf import settings from django.conf import settings
from django.db import transaction from django.db import transaction
from django.db.models import QuerySet
from cmsmanage.django_q2_helper import q_task_group from cmsmanage.django_q2_helper import q_task_group
from membershipworks.membershipworks_api import FieldType, MembershipWorks from membershipworks.membershipworks_api import FieldType, MembershipWorks
@ -125,13 +124,13 @@ def scrape_membershipworks(*args, **options):
scrape_transactions(membershipworks) scrape_transactions(membershipworks)
def scrape_event_details(queryset: QuerySet[EventExt]): def scrape_event_details(events: Iterable[EventExt]):
membershipworks = MembershipWorks() membershipworks = MembershipWorks()
membershipworks.login( membershipworks.login(
settings.MEMBERSHIPWORKS_USERNAME, settings.MEMBERSHIPWORKS_PASSWORD settings.MEMBERSHIPWORKS_USERNAME, settings.MEMBERSHIPWORKS_PASSWORD
) )
for event in queryset: for event in events:
event.details = membershipworks.get_event_by_eid(event.eid) event.details = membershipworks.get_event_by_eid(event.eid)
event.registrations = membershipworks.get_event_registrations(event.eid) event.registrations = membershipworks.get_event_registrations(event.eid)
event.save() event.save()

View File

@ -0,0 +1,10 @@
<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>

View File

@ -13,10 +13,16 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class="row justify-content-center d-print-none">
<div class="col-auto">
{% if event.registrations is not None %} {% if event.registrations is not None %}
{% url 'membershipworks:event-registrations' event.pk as registrations_url %} {% url 'membershipworks:event-registrations' event.pk as registrations_url %}
{% bootstrap_button href=registrations_url content="Show Registrations" %} {% bootstrap_button extra_classes="btn-sm" href=registrations_url content="Show Registrations" %}
{% endif %} {% endif %}
</div>
<div class="col-auto">{% include "membershipworks/components/refresh_data_button.dj.html" %}</div>
</div>
{% include "membershipworks/event_invoice.dj.html" %} {% include "membershipworks/event_invoice.dj.html" %}
<div class="card w-auto mt-5"> <div class="card w-auto mt-5">

View File

@ -22,6 +22,7 @@
{% bootstrap_button extra_classes="btn-sm" href=email_link target="_blank" content="Email all attendees" %} {% bootstrap_button extra_classes="btn-sm" href=email_link target="_blank" content="Email all attendees" %}
</div> </div>
<div class="col-auto">{% include "cmsmanage/components/download_table.dj.html" %}</div> <div class="col-auto">{% include "cmsmanage/components/download_table.dj.html" %}</div>
<div class="col-auto">{% include "membershipworks/components/refresh_data_button.dj.html" %}</div>
</div> </div>
<h2 class="d-none d-print-block">Registrations for {{ event.details.ttl|nh3 }}</h2> <h2 class="d-none d-print-block">Registrations for {{ event.details.ttl|nh3 }}</h2>
{% render_table table %} {% render_table table %}

View File

@ -41,6 +41,7 @@ from django_weasyprint import WeasyTemplateResponseMixin
from django_weasyprint.utils import django_url_fetcher from django_weasyprint.utils import django_url_fetcher
from membershipworks.membershipworks_api import MembershipWorks from membershipworks.membershipworks_api import MembershipWorks
from membershipworks.tasks.scrape import scrape_event_details, scrape_events
from .forms import EventInvoiceForm from .forms import EventInvoiceForm
from .invoice_email import make_invoice_emails from .invoice_email import make_invoice_emails
@ -310,6 +311,10 @@ class EventDetailView(
if self.request.user.has_perm( if self.request.user.has_perm(
self.permission_required self.permission_required
) or self.object.user_is_instructor(self.request.user): ) 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) return super().render_to_response(context, **response_kwargs)
else: else:
return self.handle_no_permission() return self.handle_no_permission()
@ -453,6 +458,9 @@ class EventRegistrationsView(ExportMixin, SingleTableMixin, AccessMixin, DetailV
def render_to_response( def render_to_response(
self, context: dict[str, Any], **response_kwargs: Any self, context: dict[str, Any], **response_kwargs: Any
) -> HttpResponse: ) -> HttpResponse:
if "refresh" in self.request.GET:
scrape_event_details([self.object])
if self.request.user.has_perm( if self.request.user.has_perm(
self.permission_required self.permission_required
) or self.object.user_is_instructor(self.request.user): ) or self.object.user_is_instructor(self.request.user):