From 020b08f9b04ab475a8c9c7b1b1a82b84b2e882f8 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sat, 20 May 2023 15:24:24 +0100 Subject: [PATCH] Default venue to event venue in EC/PT --- RIGS/forms.py | 6 ++++++ RIGS/templates/hs/event_checklist_form.html | 4 +--- RIGS/templates/hs/power_form.html | 4 ---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/RIGS/forms.py b/RIGS/forms.py index c5e5de66..17ba4acd 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -190,6 +190,8 @@ class EventRiskAssessmentForm(forms.ModelForm): class EventChecklistForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + if self.instance.event.venue: + self.fields['venue'].initial = self.instance.event.venue self.fields['date'].widget.format = '%Y-%m-%d' for name, field in self.fields.items(): if field.__class__ == forms.NullBooleanField: @@ -211,6 +213,10 @@ class EventChecklistForm(forms.ModelForm): class PowerTestRecordForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + if self.instance.event.venue: + self.fields['venue'].initial = self.instance.event.venue + if self.instance.event.riskassessment.power_mic: + self.fields['power_mic'].initial = self.instance.event.riskassessment.power_mic for name, field in self.fields.items(): if field.__class__ == forms.NullBooleanField: # Only display yes/no to user, the 'none' is only ever set in the background diff --git a/RIGS/templates/hs/event_checklist_form.html b/RIGS/templates/hs/event_checklist_form.html index ea8183a1..373ad306 100644 --- a/RIGS/templates/hs/event_checklist_form.html +++ b/RIGS/templates/hs/event_checklist_form.html @@ -24,7 +24,7 @@ {% block content %}
{% include 'form_errors.html' %} - +
@@ -59,8 +59,6 @@
diff --git a/RIGS/templates/hs/power_form.html b/RIGS/templates/hs/power_form.html index 64e5bf18..d77ead1b 100644 --- a/RIGS/templates/hs/power_form.html +++ b/RIGS/templates/hs/power_form.html @@ -54,8 +54,6 @@ @@ -65,8 +63,6 @@