Skip to content

Commit

Permalink
Add Superstars report
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsuta committed Nov 1, 2024
1 parent 936e2f6 commit 798dfeb
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 3 deletions.
4 changes: 4 additions & 0 deletions magprime/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def SEASON_BADGE_PRICE(self):
@property
def SEASON_EVENTS(self):
return config['season_events']

@property
def SUPERSTAR_MINIMUM(self):
return list(c.SUPERSTAR_DONATIONS.keys())[1]

@property
def PREREG_BADGE_TYPES(self):
Expand Down
5 changes: 3 additions & 2 deletions magprime/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def check_in_notes(self):

@presave_adjustment
def set_superstar_ribbon(self):
if self.extra_donation >= 30 and c.SUPERSTAR_RIBBON not in self.ribbon_ints:
if self.extra_donation >= c.SUPERSTAR_MINIMUM and c.SUPERSTAR_RIBBON not in self.ribbon_ints:
self.ribbon = add_opt(self.ribbon_ints, c.SUPERSTAR_RIBBON)
elif self.extra_donation < 30 and self.orig_value_of('extra_donation') >= 30 and c.SUPERSTAR_RIBBON in self.ribbon_ints:
elif self.extra_donation < c.SUPERSTAR_MINIMUM and \
self.orig_value_of('extra_donation') >= c.SUPERSTAR_MINIMUM and c.SUPERSTAR_RIBBON in self.ribbon_ints:
self.ribbon = remove_opt(self.ribbon_ints, c.SUPERSTAR_RIBBON)

@presave_adjustment
Expand Down
35 changes: 35 additions & 0 deletions magprime/site_sections/magprime_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sqlalchemy.orm import subqueryload

from uber.config import c
from uber.custom_tags import datetime_local_filter
from uber.decorators import all_renderable, csv_file, department_id_adapter
from uber.models import Attendee, Shift, RoomAssignment

Expand Down Expand Up @@ -66,6 +67,40 @@ def label(s):
'counts': counts,
}

def superstars(self, session):
counts = {}
owe_money = {}
superstars = session.valid_attendees().filter(Attendee.extra_donation >= c.SUPERSTAR_MINIMUM)

valid_donations_list = c.SUPERSTAR_DONATION_OPTS[1:-1]
last_index = len(valid_donations_list) - 1
for index, opt in enumerate(valid_donations_list):
amt, label = opt
count_query = session.valid_attendees().filter(Attendee.extra_donation >= amt)
if index != last_index:
next_amt, next_label = valid_donations_list[index + 1]
count_query = count_query.filter(Attendee.extra_donation < next_amt)
counts[label] = count_query.count()

for attendee in [a for a in superstars if a.amount_unpaid]:
owe_money[attendee.id] = attendee.amount_unpaid

return {
'attendees': superstars,
'counts': counts,
'owe_money': owe_money,
'total_count': superstars.count(),
}

@csv_file
def superstars_csv(self, out, session):
out.writerow(["Group Name", "Full Name", "Name on ID", "Badge Name", "Badge Type", "Ribbons", "Pre-ordered Merch",
"Email", "ZIP/Postal Code", "Checked In"])
for a in session.valid_attendees().filter(Attendee.extra_donation >= c.SUPERSTAR_MINIMUM):
out.writerow([a.group_name, a.full_name, a.legal_name, a.badge_printed_name, a.badge_type_label,
' / '.join(a.ribbon_labels), a.amount_extra_label, a.email, a.zip_code,
datetime_local_filter(a.checked_in)])

@csv_file
def donated_badge_attendees(self, out, session):
out.writerow(["Full Name", "Legal Name", "Email", "Phone #", "Amount Paid", "Amount Unpaid", "Kick-In Level",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
Thank you so much for your support! Your employer may match your contributions to charitable organizations,
so be sure to ask them. Donations over $250 will receive a donation receipt later this year. If you require a
receipt, but donated less than $250, please email {{ "[email protected]"|email_to_link }} to request one.
{% if attendee.extra_donation > 30 %}Even cooler, you are now a proud MAGFest Superstar! Check out our <a href="http://magfest.org/superstars">Superstars page</a> for more details on your perks.{% endif %}
{% if attendee.extra_donation > c.SUPERSTAR_MINIMUM %}Even cooler, you are now a proud MAGFest Superstar! Check out our <a href="http://magfest.org/superstars">Superstars page</a> for more details on your perks.{% endif %}
{% endif %}

{% if attendee.addons %}
Expand Down
67 changes: 67 additions & 0 deletions magprime/templates/magprime_reports/superstars.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% extends "uber/templates/base.html" %}{% set admin_area=True %}
{% set title = "Super MAGFest Superstars Report" %}
{% block content %}
<h2 class="center">Super MAGFest Superstars Report</h2>

<div class="card">
<div class="card-header">Superstar Counts</div>
<div class="card-body">
<p><strong>{{ total_count }}</strong> Superstars total</p>
<p>Superstar level counts:
<ul>
{% for label, count in counts.items() %}
<li><strong>{{ label }}</strong>: {{ count }}</li>
{% endfor %}
</ul>
The counts above include all donations up to but not including the next donation level.
</p>
</div>
</div>
<br/>
<div class="card">
<div class="card-header">Superstar Attendees</div>
<div class="card-body">
<p><a href="superstars_csv"><i class="fa fa-download"></i> Download CSV</a></p>
<table class="table table-striped datatable">
<thead>
<th>Group</th>
<th>Name</th>
<th>Name on Photo ID</th>
<th>Badge Name</th>
<th>Badge Type</th>
<th>Ribbons</th>
<th>Pre-ordered Merch</th>
<th>Email Address</th>
<th>Zip Code</th>
<th>Paid?</th>
<th>Checked In?</th>
</thead>
<tbody>
{% for attendee in attendees %}
<tr>
<td data-sort="{{ attendee.group.name if attendee.group else '' }}">
{{ attendee.group|form_link if attendee.group else "N/A" }}
</td>
<td data-sort="{{ attendee.last_first }}">{{ attendee|form_link }}</td>
<td>{{ attendee.legal_name }}</td>
<td>{{ attendee.badge_printed_name }}</td>
<td>{{ attendee.badge_type_label }}</td>
<td>{{ attendee.ribbon_labels|join(", ") }}</td>
<td>{{ attendee.amount_extra_label }}</td>
<td>{{ attendee.email_address }}</td>
<td>{{ attendee.zip_code }}</td>
<td data-sort="{{ owe_money[attendee.id] if attendee.id in owe_money else '0' }}">
{% if owe_money[attendee.id] %}No (owes {{ owe_money[attendee.id]|format_currency }})
{% else %}Yes{% endif %}
</td>
<td data-sort="{{ attendee.checked_in|full_datetime_local }}">
{{ hour_day_local(attendee.checked_in) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

{% endblock %}

0 comments on commit 798dfeb

Please sign in to comment.