From 63db6e03babdc3f2172136acaff3d9d3c1eded5a Mon Sep 17 00:00:00 2001 From: Victoria Earl Date: Fri, 17 Nov 2023 21:22:27 -0500 Subject: [PATCH] Update events tied to panel apps when they are updated Requested via Slack. Also fixes a really annoying bug where if you had "None" for granular rating selected, the box would always be unchecked when you loaded and application. --- uber/models/panels.py | 7 +++++++ uber/templates/panel_app_form_new.html | 7 +++---- uber/templates/panels_admin/form.html | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/uber/models/panels.py b/uber/models/panels.py index 33770ad6d..07a66b8aa 100644 --- a/uber/models/panels.py +++ b/uber/models/panels.py @@ -8,6 +8,7 @@ from sqlalchemy.ext.hybrid import hybrid_property from uber.config import c +from uber.decorators import presave_adjustment from uber.models import MagModel from uber.models.types import default_relationship as relationship, utcnow, Choice, DefaultColumn as Column, \ MultiChoice, SocialMediaMixin @@ -136,6 +137,12 @@ class PanelApplication(MagModel): email_model_name = 'app' + @presave_adjustment + def update_event_info(self): + if self.event: + self.event.name = self.name + self.event.description = self.description + @property def email(self): return self.submitter and self.submitter.email diff --git a/uber/templates/panel_app_form_new.html b/uber/templates/panel_app_form_new.html index 0d2312c3b..c4462f084 100644 --- a/uber/templates/panel_app_form_new.html +++ b/uber/templates/panel_app_form_new.html @@ -43,7 +43,6 @@ showOrHideLengthReason(); showOrHideModHelp(); showOrHideLoud(); - controlGranularRatingCheckboxes(); $.field('presentation').on('change', showOrHideOtherPresentation); $.field('presentation').on('change', showOrHideModHelp); $.field('presentation').on('change', showOrHideLoud); @@ -160,10 +159,10 @@ $(function () { if ($.field('granular_rating')) { $.field('magscouts_opt_in').parents('.form-group').insertAfter($.field('granular_rating').parents('.form-group')); + $.field('granular_rating').on('change', showOrHideOtherMAGScouts); + setVisible($.field('magscouts_opt_in').parents('.form-group'), + $(':checkbox[name=granular_rating][value={{ c.NONE }}]').prop('checked')) } - - showOrHideOtherMAGScouts(); - $.field('granular_rating').on('change', showOrHideOtherMAGScouts); }); {% endif %} diff --git a/uber/templates/panels_admin/form.html b/uber/templates/panels_admin/form.html index afd2639c7..f768e55bf 100644 --- a/uber/templates/panels_admin/form.html +++ b/uber/templates/panels_admin/form.html @@ -1,5 +1,5 @@ {% extends "base.html" %}{% set admin_area=True %} -{% block title %}Edit Panel Application{% endblock %}} +{% block title %}Edit Panel Application{% endblock %} {% block content %} {% include "panels_common.html" %}