Skip to content

Commit

Permalink
Add counts for shirts that were opted out of
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kitsuta committed Dec 21, 2024
1 parent d41f50d commit 2ed7115
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion uber/site_sections/merch_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'):
Expand Down
28 changes: 20 additions & 8 deletions uber/site_sections/merch_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2ed7115

Please sign in to comment.