|
5 | 5 | from sqlalchemy.orm import subqueryload
|
6 | 6 |
|
7 | 7 | from uber.config import c
|
| 8 | +from uber.custom_tags import datetime_local_filter |
8 | 9 | from uber.decorators import all_renderable, csv_file, department_id_adapter
|
9 | 10 | from uber.models import Attendee, Shift, RoomAssignment
|
10 | 11 |
|
@@ -66,6 +67,40 @@ def label(s):
|
66 | 67 | 'counts': counts,
|
67 | 68 | }
|
68 | 69 |
|
| 70 | + def superstars(self, session): |
| 71 | + counts = {} |
| 72 | + owe_money = {} |
| 73 | + superstars = session.valid_attendees().filter(Attendee.extra_donation >= c.SUPERSTAR_MINIMUM) |
| 74 | + |
| 75 | + valid_donations_list = c.SUPERSTAR_DONATION_OPTS[1:-1] |
| 76 | + last_index = len(valid_donations_list) - 1 |
| 77 | + for index, opt in enumerate(valid_donations_list): |
| 78 | + amt, label = opt |
| 79 | + count_query = session.valid_attendees().filter(Attendee.extra_donation >= amt) |
| 80 | + if index != last_index: |
| 81 | + next_amt, next_label = valid_donations_list[index + 1] |
| 82 | + count_query = count_query.filter(Attendee.extra_donation < next_amt) |
| 83 | + counts[label] = count_query.count() |
| 84 | + |
| 85 | + for attendee in [a for a in superstars if a.amount_unpaid]: |
| 86 | + owe_money[attendee.id] = attendee.amount_unpaid |
| 87 | + |
| 88 | + return { |
| 89 | + 'attendees': superstars, |
| 90 | + 'counts': counts, |
| 91 | + 'owe_money': owe_money, |
| 92 | + 'total_count': superstars.count(), |
| 93 | + } |
| 94 | + |
| 95 | + @csv_file |
| 96 | + def superstars_csv(self, out, session): |
| 97 | + out.writerow(["Group Name", "Full Name", "Name on ID", "Badge Name", "Badge Type", "Ribbons", "Pre-ordered Merch", |
| 98 | + "Email", "ZIP/Postal Code", "Checked In"]) |
| 99 | + for a in session.valid_attendees().filter(Attendee.extra_donation >= c.SUPERSTAR_MINIMUM): |
| 100 | + out.writerow([a.group_name, a.full_name, a.legal_name, a.badge_printed_name, a.badge_type_label, |
| 101 | + ' / '.join(a.ribbon_labels), a.amount_extra_label, a.email, a.zip_code, |
| 102 | + datetime_local_filter(a.checked_in)]) |
| 103 | + |
69 | 104 | @csv_file
|
70 | 105 | def donated_badge_attendees(self, out, session):
|
71 | 106 | out.writerow(["Full Name", "Legal Name", "Email", "Phone #", "Amount Paid", "Amount Unpaid", "Kick-In Level",
|
|
0 commit comments