From a7fc7a030b856d3201ddc61485958802196d0e29 Mon Sep 17 00:00:00 2001 From: Victoria Earl Date: Wed, 15 May 2024 17:20:21 -0400 Subject: [PATCH] Add cabin purchasers report Also fixes a bug where the waiver date was tabbable, and fixes a bug where the sorting for cabins and meals was not working. --- .gitignore | 2 +- magstock/config.py | 1 + magstock/forms.py | 2 +- magstock/site_sections/magstock.py | 43 +++++++++++++++ .../templates/magstock/cabin_purchasers.html | 53 +++++++++++++++++++ .../templates/magstock/food_consumers.html | 3 +- magstock/templates/registration/index.html | 4 +- 7 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 magstock/templates/magstock/cabin_purchasers.html diff --git a/.gitignore b/.gitignore index f43041f..33211c1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,5 @@ dist .cache .eggs/ .coverage -config.ini +magstock.ini test.ini diff --git a/magstock/config.py b/magstock/config.py index 51da7e1..1a3cd2f 100644 --- a/magstock/config.py +++ b/magstock/config.py @@ -15,6 +15,7 @@ MenuItem(name='Add-Ons Purchased', href='../magstock/addons'), MenuItem(name='Tent Groupings', href='../magstock/grouped'), MenuItem(name='Food Report', href='../magstock/food_consumers'), + MenuItem(name='Cabin Report', href='../magstock/cabin_purchasers'), MenuItem(name='Campsite Assignments', href='../magstock/campsite_assignments'), MenuItem(name='Parking Info', href='../magstock/parking'), ]) diff --git a/magstock/forms.py b/magstock/forms.py index d233dc1..278c9fa 100644 --- a/magstock/forms.py +++ b/magstock/forms.py @@ -86,7 +86,7 @@ class Consents: waiver_date = DateField('Date of Signature', validators=[validators.DataRequired("No date of signature. " "Please refresh the page or contact us.")], - render_kw={'readonly': True}) + render_kw={'readonly': True, 'tabIndex': -1}) waiver_consent = BooleanField( Markup('Yes, I understand that checking this box constitutes a legal signature ' 'confirming that I acknowledge and agree to the above waiver.'), diff --git a/magstock/site_sections/magstock.py b/magstock/site_sections/magstock.py index 1e9e0bd..f6d1297 100644 --- a/magstock/site_sections/magstock.py +++ b/magstock/site_sections/magstock.py @@ -27,6 +27,21 @@ def camp_food_report(session): return total_data +def camp_cabin_report(session): + attendees_with_cabins = session.attendees_with_badges().filter(Attendee.camping_type == c.CABIN) + total_data = defaultdict(int) + + total_data['attendees'] = sorted(attendees_with_cabins.all(), key=lambda a: a.full_name) + total_data['attendee_count'] = attendees_with_cabins.count() + + for cabin_type in c.CABIN_TYPES.keys(): + total_data[cabin_type] = attendees_with_cabins.filter(Attendee.cabin_type == cabin_type).count() + total_data['type_total'] += total_data[cabin_type] + + total_data['discrepancy_count'] = total_data['attendee_count'] - total_data['type_total'] + + return total_data + @all_renderable() class Root: def grouped(self, session, noise=None, site=None, camp=None): @@ -82,6 +97,34 @@ def food_consumers_report(self, out, session): out.writerow(header_row) out.writerow(data_row) + + def cabin_purchasers(self, session): + total_data = camp_cabin_report(session) + return { + 'total_data': total_data, + } + + @csv_file + def cabin_purchasers_report(self, out, session): + total_data = camp_cabin_report(session) + header_row = [ + '# Attendees', + ] + + data_row = [ + total_data['attendee_count'], + ] + + for type, label in c.CABIN_TYPE_OPTS: + header_row.append(label) + data_row.append(total_data[type]) + + if total_data['discrepancy_count']: + header_row.append("Attendees With Null Cabins") + data_row.append(total_data['discrepancy_count']) + + out.writerow(header_row) + out.writerow(data_row) def parking(self, session): """ diff --git a/magstock/templates/magstock/cabin_purchasers.html b/magstock/templates/magstock/cabin_purchasers.html new file mode 100644 index 0000000..4c4a015 --- /dev/null +++ b/magstock/templates/magstock/cabin_purchasers.html @@ -0,0 +1,53 @@ +{% extends "uber/templates/base.html" %}{% set admin_area=True %} +{% block title %}MAGStock Cabin Report{% endblock %} +{% block content %} +

MAGStock Cabin Report

+ +
+
Cabin Totals
+
+ + Download CSV + +

{{ total_data['attendee_count'] }} attendees with cabins

+

Cabin type counts: +

    + {% for type, label in c.CABIN_TYPE_OPTS %} +
  • {{ label }}: {{ total_data[type] }}
  • + {% endfor %} +
+

+ {% if total_data['discrepancy_count'] %} +

+ {{ total_data['discrepancy_count'] }} attendees are marked as having a cabin but do not have a specific cabin type. + Please check the list below for attendees without a cabin type. +

+ {% endif %} +
+
+
+
+
Attendees with Cabins
+
+ + + + + + + + + {% for attendee in total_data['attendees'] %} + + + + + + + {% endfor %} + +
AttendeeCabin TypeGroup NameBadge Type
{{ attendee|form_link }}{{ attendee.cabin_type_label }}{{ attendee.group.name }}{{ attendee.badge_type_label }}
+
+
+ +{% endblock %} diff --git a/magstock/templates/magstock/food_consumers.html b/magstock/templates/magstock/food_consumers.html index d5a5df8..b93877e 100644 --- a/magstock/templates/magstock/food_consumers.html +++ b/magstock/templates/magstock/food_consumers.html @@ -1,5 +1,5 @@ {% extends "uber/templates/base.html" %}{% set admin_area=True %} -{% block title %}Magstock Food Report{% endblock %} +{% block title %}MAGStock Food Report{% endblock %} {% block content %}

MAGStock Food Report

@@ -21,6 +21,7 @@

MAGStock Food Report

+
Attendees with Meal Plans
diff --git a/magstock/templates/registration/index.html b/magstock/templates/registration/index.html index 164fadf..3380251 100644 --- a/magstock/templates/registration/index.html +++ b/magstock/templates/registration/index.html @@ -1,8 +1,8 @@ {% extends "uber/templates/registration/index_base.html" %} {% block tableheadings %} - Camping/Cabin Type - Meal Plan + Camping/Cabin Type + Meal Plan {{ super() }} {% endblock tableheadings %}