diff --git a/RIGS/forms.py b/RIGS/forms.py
index 6faf6e67..0d425a9e 100644
--- a/RIGS/forms.py
+++ b/RIGS/forms.py
@@ -187,6 +187,7 @@ class EventRiskAssessmentForm(forms.ModelForm):
class EventChecklistForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EventChecklistForm, self).__init__(*args, **kwargs)
+ self.fields['date'].widget.format = '%Y-%m-%d'
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
@@ -194,6 +195,11 @@ class EventChecklistForm(forms.ModelForm):
# Parsed from incoming form data by clean, then saved into models when the form is saved
items = {}
+ related_models = {
+ 'venue': models.Venue,
+ 'power_mic': models.Profile,
+ }
+
# Two possible formats
def parsedatetime(self, date_string):
try:
diff --git a/RIGS/hs.py b/RIGS/hs.py
index 188e1e46..f2843ce8 100644
--- a/RIGS/hs.py
+++ b/RIGS/hs.py
@@ -127,6 +127,12 @@ class EventChecklistEdit(generic.UpdateView):
context['event'] = ec.event
context['edit'] = True
context['page_title'] = 'Edit Event Checklist for Event {}'.format(ec.event.display_id)
+ form = context['form']
+ # Get some other objects to include in the form. Used when there are errors but also nice and quick.
+ for field, model in form.related_models.items():
+ value = form[field].value()
+ if value is not None and value != '':
+ context[field] = model.objects.get(pk=value)
return context
diff --git a/RIGS/migrations/0043_auto_20201010_1320.py b/RIGS/migrations/0043_auto_20201010_1320.py
new file mode 100644
index 00000000..74aaab87
--- /dev/null
+++ b/RIGS/migrations/0043_auto_20201010_1320.py
@@ -0,0 +1,27 @@
+# Generated by Django 3.1.2 on 2020-10-10 12:20
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('RIGS', '0042_riskassessment_supervisor_consulted'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='eventchecklist',
+ name='date',
+ field=models.DateField(default=django.utils.timezone.now),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='eventchecklist',
+ name='venue',
+ field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='RIGS.venue'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/RIGS/models.py b/RIGS/models.py
index 458b9929..20b86ddb 100644
--- a/RIGS/models.py
+++ b/RIGS/models.py
@@ -690,6 +690,7 @@ class RiskAssessment(models.Model, RevisionMixin):
'special_structures': False,
'suspended_structures': False,
}
+ #inverted_fields = filter(lambda key,value: value, expected_values.items())
class Meta:
ordering = ['event']
@@ -719,6 +720,8 @@ class EventChecklist(models.Model, RevisionMixin):
# General
power_mic = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='checklists',
verbose_name="Power MIC", on_delete=models.CASCADE, help_text="Who is the Power MIC?")
+ venue = models.ForeignKey('Venue', on_delete=models.CASCADE)
+ date = models.DateField()
# Safety Checks
safe_parking = models.BooleanField(blank=True, null=True, help_text="Vehicles parked safely?
(does not obstruct venue access)")
diff --git a/RIGS/templates/event_checklist_detail.html b/RIGS/templates/event_checklist_detail.html
index 27f271ec..d7aa983d 100644
--- a/RIGS/templates/event_checklist_detail.html
+++ b/RIGS/templates/event_checklist_detail.html
@@ -5,238 +5,248 @@
{% load button from filters %}
{% block content %}
-
List vehicles and their drivers
-| Crewmember | -Start Time | -Role | -End Time | -
|---|---|---|---|
| {{crew.crewmember}} | -{{crew.start}} | -{{crew.role}} | -{{crew.end}} | -
Tests at first distro
-| Test | -Value | -||
|---|---|---|---|
| Voltage (cube meter) |
- {{ object|help_text:'fd_voltage_l1' }} | -{{ object|help_text:'fd_voltage_l2' }} | -{{ object|help_text:'fd_voltage_l3' }} | -
| {{ object.fd_voltage_l1 }} | -{{ object.fd_voltage_l2 }} | -{{ object.fd_voltage_l3 }} | -|
| {{ object|help_text:'fd_phase_rotation'|safe }} | -{{ object.fd_phase_rotation|yesnoi }} | -||
| {{ object|help_text:'fd_earth_fault'|safe}} | -{{ object.fd_earth_fault }} | -||
| {{ object|help_text:'fd_pssc'}} | -{{ object.fd_pssc }} | -||
Tests at 'Worst Case' points (at least 1 point required)
-| Test | -Point 1 | -Point 2 | -Point 3 | -
|---|---|---|---|
| {{ object|help_text:'w1_description'|safe}} | -{{ object.w1_description }} | -{{ object.w2_description|default:'' }} | -{{ object.w3_description|default:'' }} | -
| {{ object|help_text:'w1_polarity'|safe}} | -{{ object.w1_polarity|yesnoi }} | -{{ object.w2_polarity|default:''|yesnoi }} | -{{ object.w3_polarity|default:''|yesnoi }} | -
| {{ object|help_text:'w1_voltage'|safe}} | -{{ object.w1_voltage }} | -{{ object.w2_voltage|default:'' }} | -{{ object.w3_voltage|default:'' }} | -
| {{ object|help_text:'w1_earth_fault'|safe}} | -{{ object.w1_earth_fault }} | -{{ object.w2_earth_fault|default:'' }} | -{{ object.w3_earth_fault|default:'' }} | -
List vehicles and their drivers
+| Crewmember | +Start Time | +Role | +End Time | +
|---|---|---|---|
| {{crew.crewmember}} | +{{crew.start}} | +{{crew.role}} | +{{crew.end}} | +
Tests at first distro
+| Test | +Value | +||
|---|---|---|---|
| Voltage (cube meter) |
+ {{ object|help_text:'fd_voltage_l1' }} | +{{ object|help_text:'fd_voltage_l2' }} | +{{ object|help_text:'fd_voltage_l3' }} | +
| {{ object.fd_voltage_l1 }} | +{{ object.fd_voltage_l2 }} | +{{ object.fd_voltage_l3 }} | +|
| {{ object|help_text:'fd_phase_rotation'|safe }} | +{{ object.fd_phase_rotation|yesnoi }} | +||
| {{ object|help_text:'fd_earth_fault'|safe}} | +{{ object.fd_earth_fault }} | +||
| {{ object|help_text:'fd_pssc'}} | +{{ object.fd_pssc }} | +||
Tests at 'Worst Case' points (at least 1 point required)
+| Test | +Point 1 | +Point 2 | +Point 3 | +
|---|---|---|---|
| {{ object|help_text:'w1_description'|safe}} | +{{ object.w1_description }} | +{{ object.w2_description|default:'' }} | +{{ object.w3_description|default:'' }} | +
| {{ object|help_text:'w1_polarity'|safe}} | +{{ object.w1_polarity|yesnoi }} | +{{ object.w2_polarity|default:''|yesnoi }} | +{{ object.w3_polarity|default:''|yesnoi }} | +
| {{ object|help_text:'w1_voltage'|safe}} | +{{ object.w1_voltage }} | +{{ object.w2_voltage|default:'' }} | +{{ object.w3_voltage|default:'' }} | +
| {{ object|help_text:'w1_earth_fault'|safe}} | +{{ object.w1_earth_fault }} | +{{ object.w2_earth_fault|default:'' }} | +{{ object.w3_earth_fault|default:'' }} | +
List vehicles and their drivers