Skip to content

Commit

Permalink
Add cabin purchasers report
Browse files Browse the repository at this point in the history
Also fixes a bug where the waiver date was tabbable, and fixes a bug where the sorting for cabins and meals was not working.
  • Loading branch information
kitsuta committed May 15, 2024
1 parent b166ba9 commit a7fc7a0
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dist
.cache
.eggs/
.coverage
config.ini
magstock.ini
test.ini
1 change: 1 addition & 0 deletions magstock/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
])
Expand Down
2 changes: 1 addition & 1 deletion magstock/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<strong>Yes</strong>, I understand that checking this box constitutes a legal signature '
'confirming that I acknowledge and agree to the above waiver.'),
Expand Down
43 changes: 43 additions & 0 deletions magstock/site_sections/magstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand Down
53 changes: 53 additions & 0 deletions magstock/templates/magstock/cabin_purchasers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends "uber/templates/base.html" %}{% set admin_area=True %}
{% block title %}MAGStock Cabin Report{% endblock %}
{% block content %}
<h2 class="center">MAGStock Cabin Report</h2>

<div class="card">
<div class="card-header">Cabin Totals</div>
<div class="card-body">
<a href="cabin_purchasers_report">
<span class="glyphicon glyphicon-download"></span> Download CSV
</a>
<p><strong>{{ total_data['attendee_count'] }}</strong> attendees with cabins</p>
<p>Cabin type counts:
<ul>
{% for type, label in c.CABIN_TYPE_OPTS %}
<li><strong>{{ label }}</strong>: {{ total_data[type] }}</li>
{% endfor %}
</ul>
</p>
{% if total_data['discrepancy_count'] %}
<p>
<strong>{{ total_data['discrepancy_count'] }} attendees are marked as having a cabin but do not have a specific cabin type.</strong>
Please check the list below for attendees without a cabin type.
</p>
{% endif %}
</div>
</div>
<br/>
<div class="card">
<div class="card-header">Attendees with Cabins</div>
<div class="card-body">
<table class="table table-striped datatable">
<thead>
<th>Attendee</th>
<th>Cabin Type</th>
<th>Group Name</th>
<th>Badge Type</th>
</thead>
<tbody>
{% for attendee in total_data['attendees'] %}
<tr>
<td>{{ attendee|form_link }}</td>
<td>{{ attendee.cabin_type_label }}</td>
<td>{{ attendee.group.name }}</td>
<td>{{ attendee.badge_type_label }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

{% endblock %}
3 changes: 2 additions & 1 deletion magstock/templates/magstock/food_consumers.html
Original file line number Diff line number Diff line change
@@ -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 %}
<h2 class="center">MAGStock Food Report</h2>

Expand All @@ -21,6 +21,7 @@ <h2 class="center">MAGStock Food Report</h2>
</p>
</div>
</div>
<br/>
<div class="card">
<div class="card-header">Attendees with Meal Plans</div>
<div class="card-body">
Expand Down
4 changes: 2 additions & 2 deletions magstock/templates/registration/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "uber/templates/registration/index_base.html" %}

{% block tableheadings %}
<th><a href="index?order={{ order.camping_type }}">Camping/Cabin Type</a></th>
<th><a href="index?order={{ order.meal_plan }}">Meal Plan</a></th>
<th><a href="index?order={{ order.camping_type }}&page={{ page }}&search_text={{ search_text|urlencode }}&invalid={{ invalid }}">Camping/Cabin Type</a></th>
<th><a href="index?order={{ order.meal_plan }}&page={{ page }}&search_text={{ search_text|urlencode }}&invalid={{ invalid }}">Meal Plan</a></th>
{{ super() }}
{% endblock tableheadings %}

Expand Down

0 comments on commit a7fc7a0

Please sign in to comment.