From 5ab9a3fba1f9afa1625a3bc821239129f4a491f9 Mon Sep 17 00:00:00 2001 From: Victoria Earl Date: Fri, 1 Nov 2024 15:17:14 -0400 Subject: [PATCH] Allow only text for the stage plot checklist step Requested via Slack. --- uber/site_sections/guests.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/uber/site_sections/guests.py b/uber/site_sections/guests.py index faf798606..02bcff2ff 100644 --- a/uber/site_sections/guests.py +++ b/uber/site_sections/guests.py @@ -1,6 +1,7 @@ import os import shutil +from pockets.autolog import log import cherrypy from cherrypy.lib.static import serve_file from sqlalchemy.orm.exc import NoResultFound @@ -117,13 +118,17 @@ def stage_plot(self, session, guest_id, message='', plot=None, **params): guest = session.guest_group(guest_id) guest_stage_plot = session.guest_stage_plot(params, restricted=True) if cherrypy.request.method == 'POST': - guest_stage_plot.filename = plot.filename - guest_stage_plot.content_type = plot.content_type.value - if guest_stage_plot.stage_plot_extension not in c.ALLOWED_STAGE_PLOT_EXTENSIONS: - message = 'Uploaded file type must be one of ' + ', '.join(c.ALLOWED_STAGE_PLOT_EXTENSIONS) - else: - with open(guest_stage_plot.fpath, 'wb') as f: - shutil.copyfileobj(plot.file, f) + if plot.filename: + guest_stage_plot.filename = plot.filename + guest_stage_plot.content_type = plot.content_type.value + if guest_stage_plot.stage_plot_extension not in c.ALLOWED_STAGE_PLOT_EXTENSIONS: + message = 'Uploaded file type must be one of ' + ', '.join(c.ALLOWED_STAGE_PLOT_EXTENSIONS) + else: + with open(guest_stage_plot.fpath, 'wb') as f: + shutil.copyfileobj(plot.file, f) + elif not params.get('notes'): + message = "Please either upload a stage layout or explain your inputs and stage gear needs in the Additional Notes section." + if not message: guest.stage_plot = guest_stage_plot session.add(guest_stage_plot) raise HTTPRedirect('index?id={}&message={}', guest.id, 'Stage directions uploaded')