Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update food eligible report #4378

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions uber/site_sections/other_reports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cherrypy

from sqlalchemy import or_
from uber.config import c
from uber.decorators import all_renderable, csv_file, render, site_mappable
from uber.models import Attendee, FoodRestrictions, GuestCharity
Expand All @@ -22,24 +21,38 @@ def food_restrictions(self, session):
c.FOOD_RESTRICTIONS[getattr(c, category)]: len([fr for fr in all_fr if getattr(fr, category)])
for category in c.FOOD_RESTRICTION_VARS
},
'sandwich_prefs': {
'sandwich_prefs': {~
desc: len([fr for fr in all_fr if val in fr.sandwich_pref_ints])
for val, desc in c.SANDWICH_OPTS
}
}

@csv_file
@site_mappable(download=True)
def food_eligible(self, session):
cherrypy.response.headers['Content-Type'] = 'application/xml'
eligible = {
a: {attr.lower(): getattr(a.food_restrictions, attr, False) for attr in c.FOOD_RESTRICTION_VARS}
for a in session.staffers().all() + session.query(Attendee).filter_by(badge_type=c.GUEST_BADGE).all()
if not a.is_unassigned and (
a.badge_type in (c.STAFF_BADGE, c.GUEST_BADGE)
or c.VOLUNTEER_RIBBON in a.ribbon_ints
and a.weighted_hours >= 12)
}
return render('other_reports/food_eligible.xml', {'attendees': eligible})
def food_eligible(self, out, session):
header = ['Name', 'Badge Type', 'Badge #', 'Eligible']
ordered_food_restrictions = []
for val, label in c.FOOD_RESTRICTIONS.items():
ordered_food_restrictions.append(val)
header.append(label)

header.append('Notes')
out.writerow(header)

base_query = session.attendees_with_badges().filter(Attendee.is_unassigned == False)

guests = base_query.filter_by(badge_type=c.GUEST_BADGE).all()
volunteers = [a for a in base_query.filter_by(staffing=True).all() if a.badge_type == c.STAFF_BADGE
or a.weighted_hours or not a.takes_shifts]

for a in volunteers + guests:
row = [a.full_name, a.badge_type_label, a.badge_num,
'Yes' if a.badge_type in [c.STAFF_BADGE, c.GUEST_BADGE] or (
a.weighted_hours > c.HOURS_FOR_FOOD and a.worked_hours) else 'No']
for key in ordered_food_restrictions:
row.append("Yes" if a.food_restrictions and key in a.food_restrictions.standard else "No")
row.append(a.food_restrictions.freeform if a.food_restrictions else "")
out.writerow(row)

def guest_donations(self, session):
return {
Expand Down
Loading