From 5e1e2d53f0e255d34ab84a636527b7e0f8b9ced4 Mon Sep 17 00:00:00 2001 From: Victoria Earl Date: Fri, 11 Oct 2024 16:46:40 -0400 Subject: [PATCH] Fix how guest panels are handled We had very old data in the panel-related info of the guest checklist CSV. Also, panel_applications means applications ASSIGNED to someone as POC and not applications they have submitted. I added a new relationship for submitted apps and changed the guest plugin to rely on those, which should fix various display errors on the checklist. --- uber/models/__init__.py | 2 +- uber/models/attendee.py | 7 +++++ uber/models/guests.py | 4 +-- uber/site_sections/guest_reports.py | 28 ++++++++++++++++--- uber/site_sections/panels_admin.py | 2 +- uber/templates/group_admin/guests.html | 1 + .../templates/guest_admin/checklist_info.html | 6 ++-- .../guest_checklist/band_panel_deadline.html | 6 ++-- .../guest_checklist/guest_panel_deadline.html | 6 ++-- .../guest_checklist/panel_deadline.html | 6 ++-- uber/templates/panels/guest.html | 8 +++--- 11 files changed, 52 insertions(+), 24 deletions(-) diff --git a/uber/models/__init__.py b/uber/models/__init__.py index 67de7712d..9a42d5183 100644 --- a/uber/models/__init__.py +++ b/uber/models/__init__.py @@ -865,7 +865,7 @@ def access_query_matrix(self): return_dict['panels_admin'] = self.query(Attendee).outerjoin(PanelApplicant).filter( or_(Attendee.ribbon.contains(c.PANELIST_RIBBON), - Attendee.panel_applications != None, # noqa: E711 + Attendee.submitted_panels != None, # noqa: E711 Attendee.assigned_panelists != None, # noqa: E711 Attendee.panel_applicants != None, # noqa: E711 Attendee.panel_feedback != None)) # noqa: E711 diff --git a/uber/models/attendee.py b/uber/models/attendee.py index db5a73c73..377c92569 100644 --- a/uber/models/attendee.py +++ b/uber/models/attendee.py @@ -402,6 +402,13 @@ class Attendee(MagModel, TakesPaymentMixin): panel_applicants = relationship('PanelApplicant', backref='attendee') panel_applications = relationship('PanelApplication', backref='poc') panel_feedback = relationship('EventFeedback', backref='attendee') + submitted_panels = relationship( + 'PanelApplication', + secondary='panel_applicant', + secondaryjoin='and_(PanelApplicant.app_id == PanelApplication.id)', + primaryjoin='and_(Attendee.id == PanelApplicant.attendee_id, PanelApplicant.submitter == True)', + viewonly=True + ) # ========================= # attractions diff --git a/uber/models/guests.py b/uber/models/guests.py index bbb07702d..7e0633789 100644 --- a/uber/models/guests.py +++ b/uber/models/guests.py @@ -140,9 +140,9 @@ def merch_status(self): @property def panel_status(self): - application_count = len(self.group.leader.panel_applications) + application_count = len(self.group.leader.submitted_panels) return '{} Panel Application(s)'.format(application_count) \ - if self.group.leader.panel_applications else self.status('panel') + if self.group.leader.submitted_panels else self.status('panel') @property def mc_status(self): diff --git a/uber/site_sections/guest_reports.py b/uber/site_sections/guest_reports.py index fa8f2cc5a..0178dbfa6 100644 --- a/uber/site_sections/guest_reports.py +++ b/uber/site_sections/guest_reports.py @@ -38,6 +38,9 @@ def checklist_info_csv(self, out, session): for guest in [guest for guest in session.query(GuestGroup).all() if session.admin_can_see_guest_group(guest)]: absolute_pic_url = convert_to_absolute_url(getattr(guest.bio, 'pic_url', '')) absolute_stageplot_url = convert_to_absolute_url(getattr(guest.stage_plot, 'url', '')) + num_panels = 0 if not guest.group or not guest.group.leader or not guest.group.leader.submitted_panels \ + else len(guest.group.leader.submitted_panels) + out.writerow([ guest.group_type_label, guest.group.name, guest.email, guest.payment, guest.vehicles, guest.num_hotel_rooms, @@ -49,10 +52,7 @@ def checklist_info_csv(self, out, session): getattr(guest.bio, 'twitter', ''), getattr(guest.bio, 'instagram', ''), getattr(guest.bio, 'twitch', ''), getattr(guest.bio, 'bandcamp', ''), getattr(guest.bio, 'discord', ''), getattr(guest.bio, 'other_social_media', ''), - getattr(guest.bio, 'pic_filename', ''), absolute_pic_url, - getattr(guest.panel, 'wants_panel', ''), getattr(guest.panel, 'name', ''), - getattr(guest.panel, 'length', ''), getattr(guest.panel, 'desc', ''), - ' / '.join(getattr(guest.panel, 'panel_tech_needs_labels', '')), + getattr(guest.bio, 'pic_filename', ''), absolute_pic_url, num_panels, getattr(guest.autograph, 'num', ''), getattr(guest.autograph, 'length', ''), getattr(guest.autograph, 'rock_island_autographs', ''), getattr(guest.autograph, 'rock_island_length', ''), @@ -78,6 +78,26 @@ def detailed_travel_info_csv(self, out, session): time_day_local(plan.departure_time), plan.departure_details, plan.extra_details]) out.writerow(content_row) + + @csv_file + def panel_info_csv(self, out, session): + out.writerow(['Guest', 'App Status', 'Name', 'Description', 'Schedule Description', 'Length', + 'Department', 'Type of Panel', 'Location', 'Date/Time']) + for guest in session.query(GuestGroup): + if guest.group and guest.group.leader: + for app in guest.group.leader.submitted_panels: + out.writerow([ + guest.group.name, app.status_label, + getattr(app.event, 'name', app.name), + getattr(app.event, 'description', app.description), + getattr(app.event, 'public_description', app.public_description), + f"{app.event.minutes} minutes" if app.event else f"{app.length_label} (expected)", + app.department_label, + app.other_presentation if app.presentation == c.OTHER else app.presentation_label, + getattr(app.event, 'location_label', '(not scheduled)'), + app.event.timespan(minute_increment=30) if app.event else '(not scheduled)', + ]) + @site_mappable def rock_island(self, session, message='', only_empty=None, id=None, **params): diff --git a/uber/site_sections/panels_admin.py b/uber/site_sections/panels_admin.py index 68ce2552d..99066db98 100644 --- a/uber/site_sections/panels_admin.py +++ b/uber/site_sections/panels_admin.py @@ -285,7 +285,7 @@ def everything(self, out, session): out.writerow([ app.name, app.description, - app.length, + app.length_label, app.unavailable, app.past_attendance, app.affiliations, diff --git a/uber/templates/group_admin/guests.html b/uber/templates/group_admin/guests.html index 0f137a53e..803e7e079 100644 --- a/uber/templates/group_admin/guests.html +++ b/uber/templates/group_admin/guests.html @@ -53,4 +53,5 @@

Export all checklist data as a CSV file

Autographs CSV

Detailed Travel Info CSV

+

Submitted Panels CSV

{% endif %} diff --git a/uber/templates/guest_admin/checklist_info.html b/uber/templates/guest_admin/checklist_info.html index d89fc8474..056bc6197 100644 --- a/uber/templates/guest_admin/checklist_info.html +++ b/uber/templates/guest_admin/checklist_info.html @@ -8,14 +8,14 @@

Guest Info for {{ guest.group.na {{ csrf_token() }} - {% if guest.group.leader.panel_applications %} + {% if guest.group.leader.submitted_panels %}
diff --git a/uber/templates/guest_checklist/band_panel_deadline.html b/uber/templates/guest_checklist/band_panel_deadline.html index cada19a7e..97e3ac5bf 100644 --- a/uber/templates/guest_checklist/band_panel_deadline.html +++ b/uber/templates/guest_checklist/band_panel_deadline.html @@ -1,12 +1,12 @@ {% extends "guest_checklist/panel_deadline.html" %} {% block deadline_text %} - {% if not guest.group.leader.panel_applications %} + {% if not guest.group.leader.submitted_panels %} Are you interested in running a panel at MAGFest? Please tell us what you would like to plan and our panels department will get in touch with more details. {% else %} - You have already submitted {{ guest.group.leader.panel_applications|length }} panel - idea{{ guest.group.leader.panel_applications|length|pluralize }}. + You have already submitted {{ guest.group.leader.submitted_panels|length }} panel + idea{{ guest.group.leader.submitted_panels|length|pluralize }}. {% if c.APP_LIMIT %} You may submit up to {{ c.APP_LIMIT }} panels for review. {% endif %} diff --git a/uber/templates/guest_checklist/guest_panel_deadline.html b/uber/templates/guest_checklist/guest_panel_deadline.html index 188576c72..6a22f8b66 100644 --- a/uber/templates/guest_checklist/guest_panel_deadline.html +++ b/uber/templates/guest_checklist/guest_panel_deadline.html @@ -3,11 +3,11 @@ {% block deadline_headline %}Add Your Panels{% endblock %} {% block deadline_text %} - {% if not guest.group.leader.panel_applications %} + {% if not guest.group.leader.submitted_panels %} What panels and/or events are you hosting at {{ c.EVENT_NAME }}? Please submit an application for each. {% else %} - You have already submitted {{ guest.group.leader.panel_applications|length }} panel/event - idea{{ guest.group.leader.panel_applications|length|pluralize }}. + You have already submitted {{ guest.group.leader.submitted_panels|length }} panel/event + idea{{ guest.group.leader.submitted_panels|length|pluralize }}. {% if c.APP_LIMIT %} You may submit up to {{ c.APP_LIMIT }} applications for review. {% endif %} diff --git a/uber/templates/guest_checklist/panel_deadline.html b/uber/templates/guest_checklist/panel_deadline.html index 6942c2685..9eeddc3b2 100644 --- a/uber/templates/guest_checklist/panel_deadline.html +++ b/uber/templates/guest_checklist/panel_deadline.html @@ -7,11 +7,11 @@ {% block deadline_text %} - {% if not guest.group.leader.panel_applications %} + {% if not guest.group.leader.submitted_panels %} What panels and/or events are you putting on at {{ c.EVENT_NAME }}? Please use the above link to submit each panel. {% else %} - You have already submitted {{ guest.group.leader.panel_applications|length }} panel - idea{{ guest.group.leader.panel_applications|length|pluralize }}. + You have already submitted {{ guest.group.leader.submitted_panels|length }} panel + idea{{ guest.group.leader.submitted_panels|length|pluralize }}. {% if c.APP_LIMIT %} You may submit up to {{ c.APP_LIMIT }} panels for review. {% endif %} diff --git a/uber/templates/panels/guest.html b/uber/templates/panels/guest.html index 05e28b1d1..729a43aa0 100644 --- a/uber/templates/panels/guest.html +++ b/uber/templates/panels/guest.html @@ -7,7 +7,7 @@
- {% if c.APP_LIMIT and attendee.panel_applications|length >= c.APP_LIMIT %} + {% if c.APP_LIMIT and attendee.submitted_panels|length >= c.APP_LIMIT %} You have already submitted the maximum number of panels ({{ c.APP_LIMIT }}). Please contact your liaison if you need to change a panel or submit more ideas. @@ -15,8 +15,8 @@ {% else %} {% if c.APP_LIMIT %} You may submit up to {{ c.APP_LIMIT }} panel ideas. - {% if attendee.panel_applications %} - You have already submitted {{ attendee.panel_applications|length }}. + {% if attendee.submitted_panels %} + You have already submitted {{ attendee.submitted_panels|length }}. {% endif %} {% endif %}
@@ -57,7 +57,7 @@

Other Panelists

- {% if not c.APP_LIMIT or attendee.panel_applications|length < c.APP_LIMIT %} + {% if not c.APP_LIMIT or attendee.submitted_panels|length < c.APP_LIMIT %} {% endif %}