From 8842c2c3d96d05fc5655d0aeee788a5f68714f8f Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sun, 30 Aug 2020 20:16:35 +0100 Subject: [PATCH] Worst case points on checklist --- RIGS/migrations/0053_auto_20200830_1940.py | 83 ++++++++++++++++++++++ RIGS/models.py | 33 +++++++-- RIGS/templates/event_checklist_detail.html | 74 ++++++++++++++----- RIGS/templates/event_checklist_form.html | 49 +++++++++++-- RIGS/templates/partials/ec_power_info.html | 6 +- RIGS/templates/risk_assessment_detail.html | 39 +++++----- RIGS/templatetags/filters.py | 16 +++++ 7 files changed, 250 insertions(+), 50 deletions(-) create mode 100644 RIGS/migrations/0053_auto_20200830_1940.py diff --git a/RIGS/migrations/0053_auto_20200830_1940.py b/RIGS/migrations/0053_auto_20200830_1940.py new file mode 100644 index 00000000..558dd21f --- /dev/null +++ b/RIGS/migrations/0053_auto_20200830_1940.py @@ -0,0 +1,83 @@ +# Generated by Django 3.1 on 2020-08-30 18:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0052_auto_20200830_1117'), + ] + + operations = [ + migrations.AddField( + model_name='eventchecklist', + name='w1_description', + field=models.CharField(blank=True, help_text='Description', max_length=255, null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w1_earth_fault', + field=models.IntegerField(blank=True, help_text='Earth Fault Loop Impedance (ZS)', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w1_polarity', + field=models.BooleanField(blank=True, help_text='Polarity Checked?', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w1_voltage', + field=models.IntegerField(blank=True, help_text='Voltage', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w2_description', + field=models.CharField(blank=True, help_text='Description', max_length=255, null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w2_earth_fault', + field=models.IntegerField(blank=True, help_text='Earth Fault Loop Impedance (ZS)', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w2_polarity', + field=models.BooleanField(blank=True, help_text='Polarity Checked?', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w2_voltage', + field=models.IntegerField(blank=True, help_text='Voltage', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w3_description', + field=models.CharField(blank=True, help_text='Description', max_length=255, null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w3_earth_fault', + field=models.IntegerField(blank=True, help_text='Earth Fault Loop Impedance (ZS)', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w3_polarity', + field=models.BooleanField(blank=True, help_text='Polarity Checked?', null=True), + ), + migrations.AddField( + model_name='eventchecklist', + name='w3_voltage', + field=models.IntegerField(blank=True, help_text='Voltage', null=True), + ), + migrations.AlterField( + model_name='eventchecklist', + name='all_rcds_tested', + field=models.BooleanField(blank=True, help_text='All circuit RCDs tested?
(using test button)', null=True), + ), + migrations.AlterField( + model_name='eventchecklist', + name='public_sockets_tested', + field=models.BooleanField(blank=True, help_text='Public/Performer accessible circuits tested?
(using socket tester)', null=True), + ), + ] diff --git a/RIGS/models.py b/RIGS/models.py index 3356a82d..af30365d 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -672,6 +672,19 @@ class EventChecklist(models.Model, RevisionMixin): fd_phase_rotation = models.BooleanField(blank=True,null=True,verbose_name="Phase Rotation", help_text="Phase Rotation
(if required)") fd_earth_fault = models.IntegerField(blank=True,null=True,verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (ZS)") fd_pssc = models.IntegerField(blank=True,null=True,verbose_name="PSCC", help_text="Prospective Short Circuit Current") + #Worst case points + w1_description = models.CharField(blank=True,null=True,max_length=255, help_text="Description") + w1_polarity = models.BooleanField(blank=True,null=True,help_text="Polarity Checked?") + w1_voltage = models.IntegerField(blank=True,null=True,help_text="Voltage") + w1_earth_fault = models.IntegerField(blank=True,null=True,help_text="Earth Fault Loop Impedance (ZS)") + w2_description = models.CharField(blank=True,null=True,max_length=255, help_text="Description") + w2_polarity = models.BooleanField(blank=True,null=True,help_text="Polarity Checked?") + w2_voltage = models.IntegerField(blank=True,null=True,help_text="Voltage") + w2_earth_fault = models.IntegerField(blank=True,null=True,help_text="Earth Fault Loop Impedance (ZS)") + w3_description = models.CharField(blank=True,null=True,max_length=255, help_text="Description") + w3_polarity = models.BooleanField(blank=True,null=True,help_text="Polarity Checked?") + w3_voltage = models.IntegerField(blank=True,null=True,help_text="Voltage") + w3_earth_fault = models.IntegerField(blank=True,null=True,help_text="Earth Fault Loop Impedance (ZS)") all_rcds_tested = models.BooleanField(blank=True,null=True,help_text="All circuit RCDs tested?
(using test button)") public_sockets_tested = models.BooleanField(blank=True,null=True,help_text="Public/Performer accessible circuits tested?
(using socket tester)") @@ -679,11 +692,21 @@ class EventChecklist(models.Model, RevisionMixin): def clean(self): errdict = {} if self.earthing == None or self.pat == None: - raise ValidationError('Fill out the electrical checks') - if self.medium_event and (self.source_rcd == None or self.labelling == None or self.all_rcds_tested == None or self.public_sockets_tested == None): - raise ValidationError('Fill out the medium event electrical checks') - elif self.rcds == None or self.supply_test == None: - raise ValidationError('Fill out the small event electrical checks') + errdict['earthing'] = 'Fill out the electrical checks' + + if not self.medium_event and (self.rcds == None or self.supply_test == None): + errdict['rcds'] = 'Fill out the small event electrical checks' + + if self.medium_event: + if self.source_rcd == None or self.labelling == None or self.all_rcds_tested == None or self.public_sockets_tested == None: + errdict['source_rcd'] = 'Fill out the medium event electrical checks' + + if self.w1_description == None or self.w1_polarity == None or self.w1_voltage == None or self.w1_earth_fault == None: + errdict['w1_description'] = 'Fully complete at least the first worst case point' + + if errdict != {}: # If there was an error when validation + raise ValidationError(errdict) + @property def activity_feed_string(self): diff --git a/RIGS/templates/event_checklist_detail.html b/RIGS/templates/event_checklist_detail.html index 3e0f0fec..28fe8063 100644 --- a/RIGS/templates/event_checklist_detail.html +++ b/RIGS/templates/event_checklist_detail.html @@ -2,6 +2,7 @@ {% block title %}Event Checklist for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}{% endblock %} {% load help_text from filters %} {% load profile_by_index from filters %} +{% load yesnoi from filters %} {% block content %}
@@ -40,27 +41,27 @@
{{ object|help_text:'safe_parking'|safe }}
- {{ object.safe_parking|yesno|title }} + {{ object.safe_parking|yesnoi }}
{{ object|help_text:'safe_packing'|safe }}
- {{ object.safe_packing|yesno|title }} + {{ object.safe_packing|yesnoi }}
{{ object|help_text:'exits'|safe }}
- {{ object.exits|yesno|title }} + {{ object.exits|yesnoi }}
{{ object|help_text:'trip_hazard'|safe }}
- {{ object.trip_hazard|yesno|title }} + {{ object.trip_hazard|yesnoi }}
{{ object|help_text:'warning_signs'|safe }}
- {{ object.warning_signs|yesno|title }} + {{ object.warning_signs|yesnoi }}
{{ object|help_text:'ear_plugs'|safe }}
- {{ object.ear_plugs|yesno|title }} + {{ object.ear_plugs|yesnoi }}
@@ -97,19 +98,19 @@
{{ object|help_text:'source_rcd'|safe }}
- {{ object.source_rcd|yesno|title }} + {{ object.source_rcd|yesnoi }}
{{ object|help_text:'labelling'|safe }}
- {{ object.labelling|yesno|title }} + {{ object.labelling|yesnoi }}
{{ object|help_text:'earthing'|safe }}
- {{ object.earthing|yesno|title }} + {{ object.earthing|yesnoi }}
{{ object|help_text:'pat'|safe }}
- {{ object.pat|yesno|title }} + {{ object.pat|yesnoi }}

@@ -135,7 +136,7 @@ {{ object|help_text:'fd_phase_rotation'|safe }} - {{ object.fd_phase_rotation|yesno|title }} + {{ object.fd_phase_rotation|yesnoi }} {{ object|help_text:'fd_earth_fault'|safe}} @@ -148,34 +149,73 @@
+

Tests at 'Worst Case' points (at least 1 point required)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestPoint 1Point 2Point 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:'' }}
+
{{ object|help_text:'all_rcds_tested'|safe }}
- {{ object.all_rcds_tested|yesno|title }} + {{ object.all_rcds_tested|yesnoi }}
{{ object|help_text:'public_sockets_tested'|safe }}
- {{ object.public_sockets_tested|yesno|title }} + {{ object.public_sockets_tested|yesnoi }}
+
{% include 'partials/ec_power_info.html' %} {% else %}
{{ object|help_text:'rcds'|safe }}
- {{ object.rcds|yesno|title }} + {{ object.rcds|yesnoi }}
{{ object|help_text:'supply_test'|safe }}
- {{ object.supply_test|yesno|title }} + {{ object.supply_test|yesnoi }}
{{ object|help_text:'earthing'|safe }}
- {{ object.earthing|yesno|title }} + {{ object.earthing|yesnoi }}
{{ object|help_text:'pat'|safe }}
- {{ object.pat|yesno|title }} + {{ object.pat|yesnoi }}
{% endif %} diff --git a/RIGS/templates/event_checklist_form.html b/RIGS/templates/event_checklist_form.html index d6be3c53..ae3827d5 100644 --- a/RIGS/templates/event_checklist_form.html +++ b/RIGS/templates/event_checklist_form.html @@ -79,7 +79,7 @@ $(".selectpicker").each(function(){initPicker($(this))}); $(target).attr('data-pk', newID - 1); }); - $('button[data-action=delete]').on('click', function(event) { + $(document).on('click', 'button[data-action=delete]', function(event) { event.preventDefault(); $(this).closest('tr').remove(); }); @@ -111,13 +111,13 @@
Event Date
-
{{form.event.start_date}}
+
{{ event.start_date}}{%if event.end_date %}-{{ event.end_date}}{%endif%}
Event Name
-
{{form.event.name}}
+
{{ event.name }}
Client
-
{{form.event.person}}
+
{{ event.person }}
Venue
-
{{form.event.Venue}}
+
{{ event.venue }}
@@ -143,7 +143,6 @@