From 2ed7115ca9cdf3d5000f3a7d186c361d238993b7 Mon Sep 17 00:00:00 2001 From: Victoria Earl Date: Fri, 20 Dec 2024 19:48:00 -0500 Subject: [PATCH] Add counts for shirts that were opted out of This counts just the number of attendees who opted out, not how many shirts they 'would' have gotten. Also puts the merch admin index page back on the sitemap. Requested via Slack. --- uber/site_sections/merch_admin.py | 3 ++- uber/site_sections/merch_reports.py | 28 ++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/uber/site_sections/merch_admin.py b/uber/site_sections/merch_admin.py index c106e60af..e27203fe3 100644 --- a/uber/site_sections/merch_admin.py +++ b/uber/site_sections/merch_admin.py @@ -4,7 +4,7 @@ from sqlalchemy import or_ from uber.config import c -from uber.decorators import ajax, all_renderable, credit_card, public, kiosk_login +from uber.decorators import ajax, all_renderable, credit_card, public, kiosk_login, site_mappable from uber.errors import HTTPRedirect from uber.models import ArbitraryCharge, Attendee, MerchDiscount, MerchPickup, \ MPointsForCash, NoShirt, OldMPointExchange @@ -37,6 +37,7 @@ def attendee_from_id_or_badge_num(session, badge_num_or_qr_code): @all_renderable() class Root: + @site_mappable @kiosk_login() def index(self, session, message='', **params): if params.get('enter_kiosk'): diff --git a/uber/site_sections/merch_reports.py b/uber/site_sections/merch_reports.py index c04ff3270..3c4075635 100644 --- a/uber/site_sections/merch_reports.py +++ b/uber/site_sections/merch_reports.py @@ -30,17 +30,29 @@ def shirt_manufacturing_counts(self, session): - attendees (who can pre-order them) """ counts = defaultdict(lambda: defaultdict(int)) - labels = ['size unknown'] + [label for val, label in c.SHIRT_OPTS][1:] - staff_labels = ['size unknown'] + [label for val, label in c.STAFF_SHIRT_OPTS][1:] + labels = ['size unknown', 'opted out'] + [label for val, label in c.SHIRT_OPTS][1:] + staff_labels = ['size unknown', 'opted out'] + [label for val, label in c.STAFF_SHIRT_OPTS][1:] for attendee in session.all_attendees(): - shirt_label = attendee.shirt_label or 'size unknown' - if c.STAFF_SHIRT_OPTS != c.SHIRT_OPTS: - staff_shirt_label = attendee.staff_shirt_label or 'size unknown' + if attendee.shirt_opt_out == c.ALL_OPT_OUT: + counts['staff']['opted out'] += 1 + counts['event']['opted out'] += 1 else: - staff_shirt_label = attendee.shirt_label or 'size unknown' - counts['staff'][label(staff_shirt_label)] += attendee.num_staff_shirts_owed - counts['event'][label(shirt_label)] += attendee.num_event_shirts_owed + shirt_label = attendee.shirt_label or 'size unknown' + if c.STAFF_SHIRT_OPTS != c.SHIRT_OPTS: + staff_shirt_label = attendee.staff_shirt_label or 'size unknown' + else: + staff_shirt_label = attendee.shirt_label or 'size unknown' + + if attendee.shirt_opt_out == c.STAFF_OPT_OUT: + counts['staff']['opted out'] += 1 + else: + counts['staff'][label(staff_shirt_label)] += attendee.num_staff_shirts_owed + + if attendee.shirt_opt_out == c.EVENT_OPT_OUT: + counts['event']['opted out'] += 1 + else: + counts['event'][label(shirt_label)] += attendee.num_event_shirts_owed categories = [] if c.SHIRTS_PER_STAFFER > 0: