Worst case points on checklist

This commit is contained in:
2020-08-30 20:16:35 +01:00
parent f3c2ce2519
commit 8842c2c3d9
7 changed files with 250 additions and 50 deletions

View File

@@ -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 (Z<small>S</small>)', 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 (Z<small>S</small>)', 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 (Z<small>S</small>)', 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?<br><small>(using test button)</small>', null=True),
),
migrations.AlterField(
model_name='eventchecklist',
name='public_sockets_tested',
field=models.BooleanField(blank=True, help_text='Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>', null=True),
),
]

View File

@@ -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<br><small>(if required)</small>")
fd_earth_fault = models.IntegerField(blank=True,null=True,verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
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 (Z<small>S</small>)")
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 (Z<small>S</small>)")
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 (Z<small>S</small>)")
all_rcds_tested = models.BooleanField(blank=True,null=True,help_text="All circuit RCDs tested?<br><small>(using test button)</small>")
public_sockets_tested = models.BooleanField(blank=True,null=True,help_text="Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>")
@@ -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):

View File

@@ -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 %}
<div class="row my-3 py-3">
@@ -40,27 +41,27 @@
<dl class="row">
<dt class="col-10">{{ object|help_text:'safe_parking'|safe }}</dt>
<dd class="col-2">
{{ object.safe_parking|yesno|title }}
{{ object.safe_parking|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'safe_packing'|safe }}</dt>
<dd class="col-2">
{{ object.safe_packing|yesno|title }}
{{ object.safe_packing|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'exits'|safe }}</dt>
<dd class="col-2">
{{ object.exits|yesno|title }}
{{ object.exits|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'trip_hazard'|safe }}</dt>
<dd class="col-2">
{{ object.trip_hazard|yesno|title }}
{{ object.trip_hazard|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'warning_signs'|safe }}</dt>
<dd class="col-2">
{{ object.warning_signs|yesno|title }}
{{ object.warning_signs|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'ear_plugs'|safe }}</dt>
<dd class="col-2">
{{ object.ear_plugs|yesno|title }}
{{ object.ear_plugs|yesnoi }}
</dd>
</dl>
</div>
@@ -97,19 +98,19 @@
<dl class="row">
<dt class="col-10">{{ object|help_text:'source_rcd'|safe }}</dt>
<dd class="col-2">
{{ object.source_rcd|yesno|title }}
{{ object.source_rcd|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'labelling'|safe }}</dt>
<dd class="col-2">
{{ object.labelling|yesno|title }}
{{ object.labelling|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'earthing'|safe }}</dt>
<dd class="col-2">
{{ object.earthing|yesno|title }}
{{ object.earthing|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'pat'|safe }}</dt>
<dd class="col-2">
{{ object.pat|yesno|title }}
{{ object.pat|yesnoi }}
</dd>
</dl>
<hr>
@@ -135,7 +136,7 @@
</tr>
<tr>
<th scope="row">{{ object|help_text:'fd_phase_rotation'|safe }}</th>
<td colspan="3">{{ object.fd_phase_rotation|yesno|title }}</td>
<td colspan="3">{{ object.fd_phase_rotation|yesnoi }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'fd_earth_fault'|safe}}</th>
@@ -148,34 +149,73 @@
</tbody>
</table>
<hr>
<p>Tests at 'Worst Case' points (at least 1 point required)</p>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col" class="text-center">Test</th>
<th scope="col" class="text-center">Point 1</th>
<th scope="col" class="text-center">Point 2</th>
<th scope="col" class="text-center">Point 3</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">{{ object|help_text:'w1_description'|safe}}</th>
<td>{{ object.w1_description }}</td>
<td>{{ object.w2_description|default:'' }}</td>
<td>{{ object.w3_description|default:'' }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'w1_polarity'|safe}}</th>
<td>{{ object.w1_polarity|yesnoi }}</td>
<td>{{ object.w2_polarity|default:''|yesnoi }}</td>
<td>{{ object.w3_polarity|default:''|yesnoi }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'w1_voltage'|safe}}</th>
<td>{{ object.w1_voltage }}</td>
<td>{{ object.w2_voltage|default:'' }}</td>
<td>{{ object.w3_voltage|default:'' }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'w1_earth_fault'|safe}}</th>
<td>{{ object.w1_earth_fault }}</td>
<td>{{ object.w2_earth_fault|default:'' }}</td>
<td>{{ object.w3_earth_fault|default:'' }}</td>
</tr>
</tbody>
</table>
<hr>
<dl class="row">
<dt class="col-10">{{ object|help_text:'all_rcds_tested'|safe }}</dt>
<dd class="col-2">
{{ object.all_rcds_tested|yesno|title }}
{{ object.all_rcds_tested|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'public_sockets_tested'|safe }}</dt>
<dd class="col-2">
{{ object.public_sockets_tested|yesno|title }}
{{ object.public_sockets_tested|yesnoi }}
</dd>
</dl>
<hr>
{% include 'partials/ec_power_info.html' %}
{% else %}
<dl class="row">
<dt class="col-10">{{ object|help_text:'rcds'|safe }}</dt>
<dd class="col-2">
{{ object.rcds|yesno|title }}
{{ object.rcds|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'supply_test'|safe }}</dt>
<dd class="col-2">
{{ object.supply_test|yesno|title }}
{{ object.supply_test|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'earthing'|safe }}</dt>
<dd class="col-2">
{{ object.earthing|yesno|title }}
{{ object.earthing|yesnoi }}
</dd>
<dt class="col-10">{{ object|help_text:'pat'|safe }}</dt>
<dd class="col-2">
{{ object.pat|yesno|title }}
{{ object.pat|yesnoi }}
</dd>
</dl>
{% endif %}

View File

@@ -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 @@
<div class="card-body">
<dl class="col-12 row">
<dt class="col-4">Event Date</dt>
<dd class="col-8">{{form.event.start_date}}</dd>
<dd class="col-8">{{ event.start_date}}{%if event.end_date %}-{{ event.end_date}}{%endif%}</dd>
<dt class="col-4">Event Name</dt>
<dd class="col-8">{{form.event.name}}</dd>
<dd class="col-8">{{ event.name }}</dd>
<dt class="col-4">Client</dt>
<dd class="col-8">{{form.event.person}}</dd>
<dd class="col-8">{{ event.person }}</dd>
<dt class="col-4">Venue</dt>
<dd class="col-8">{{form.event.Venue}}</dd>
<dd class="col-8">{{ event.venue }}</dd>
</dl>
<label for="{{ form.power_mic.id_for_label }}"
class="col-4 control-label">{{ form.power_mic.help_text }}</label>
@@ -143,7 +143,6 @@
<td><select class="form-control" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" name="driver_new" disabled="true"></select></td>
<td><button class="btn btn-danger" data-action='delete' data-target='#vehicle'><span class="fas fa-times"></span></button</td>
</tr>
{# TODO Add required to all fields on row when one is edited #}
{% for i in object.vehicles.all %}
<tr id="vehicles_{{i.pk}}">
<td><input name="vehicle_{{i.pk}}" type="text" class="form-control" value="{{ i.vehicle }}"/></td>
@@ -304,6 +303,44 @@
</tbody>
</table>
<hr>
<p>Tests at 'Worst Case' points (at least 1 point required)</p>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col" class="text-center">Test</th>
<th scope="col" class="text-center">Point 1</th>
<th scope="col" class="text-center">Point 2</th>
<th scope="col" class="text-center">Point 3</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">{{form.w1_description.help_text|safe}}</th>
<td>{% render_field form.w1_description class+="form-control" %}</td>
<td>{% render_field form.w2_description class+="form-control" %}</td>
<td>{% render_field form.w3_description class+="form-control" %}</td>
</tr>
<tr>
<th scope="row">{{form.w1_polarity.help_text|safe}}</th>
<td>{% render_field form.w1_polarity %}</td>
<td>{% render_field form.w2_polarity %}</td>
<td>{% render_field form.w3_polarity %}</td>
</tr>
<tr>
<th scope="row">{{form.w1_voltage.help_text|safe}}</th>
<td>{% render_field form.w1_voltage class+="form-control" %}</td>
<td>{% render_field form.w2_voltage class+="form-control" %}</td>
<td>{% render_field form.w3_voltage class+="form-control" %}</td>
</tr>
<tr>
<th scope="row">{{form.w1_earth_fault.help_text|safe}}</th>
<td>{% render_field form.w1_earth_fault class+="form-control" %}</td>
<td>{% render_field form.w2_earth_fault class+="form-control" %}</td>
<td>{% render_field form.w3_earth_fault class+="form-control" %}</td>
</tr>
</tbody>
</table>
<hr>
{% include 'partials/checklist_checkbox.html' with formitem=form.all_rcds_tested %}
{% include 'partials/checklist_checkbox.html' with formitem=form.public_sockets_tested %}
{% include 'partials/ec_power_info.html' %}

View File

@@ -1,7 +1,7 @@
<h3 class="py-3">Threshhold Values</h3>
<h5 class="py-3">Threshhold Values</h5>
<div class="row">
<div class="col-md-6 col-sm-12">
<table class="table">
<table class="table table-bordered">
<thead>
<tr>
<th scope="row">RCD Value (mA)</th>
@@ -28,7 +28,7 @@
</table>
</div>
<div class="col-md-6 col-sm-12">
<table class="table">
<table class="table table-bordered">
<thead>
<tr>
<th scope="row">Distro</th>

View File

@@ -1,6 +1,7 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% block title %}Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}{% endblock %}
{% load help_text from filters %}
{% load yesnoi from filters %}
{% block content %}
<div class="row my-3 py-3">
@@ -18,23 +19,23 @@
<dl class="row">
<dt class="col-10">{{ object|help_text:'nonstandard_equipment' }}</dt>
<dd class="col-2">
{{ object.nonstandard_equipment|yesno|title }}
{{ object.nonstandard_equipment|yesnoi:'invert' }}
</dd>
<dt class="col-10">{{ object|help_text:'nonstandard_use'|safe }}</dt>
<dd class="col-2">
{{ object.nonstandard_use|yesno|title }}
{{ object.nonstandard_use|yesnoi:'invert' }}
</dd>
<dt class="col-10">{{ object|help_text:'contractors' }}</dt>
<dd class="col-2">
{{ object.contractors|yesno|title }}
{{ object.contractors|yesnoi:'invert' }}
</dd>
<dt class="col-10">{{ object|help_text:'other_companies' }}</dt>
<dd class="col-2">
{{ object.othercompanies|yesno|title }}
{{ object.othercompanies|yesnoi:'invert' }}
</dd>
<dt class="col-10">{{ object|help_text:'crew_fatigue' }}</dt>
<dd class="col-2">
{{ object.crewfatigue|yesno|title }}
{{ object.crewfatigue|yesnoi:'invert' }}
</dd>
<dt class="col-12">{{ object|help_text:'general_notes' }}</dt>
<dd class="col-12">
@@ -49,7 +50,7 @@
<dl class="row">
<dt class="col-sm-6">{{ object|help_text:'big_power' }}</dt>
<dd class="col-sm-6">
{{ object.big_power|yesno|title }}
{{ object.big_power|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'power_mic' }}</dt>
<dd class="col-sm-6">
@@ -57,19 +58,19 @@
</dd>
<dt class="col-sm-6">{{ object|help_text:'generators' }}</dt>
<dd class="col-sm-6">
{{ object.generators|yesno|title }}
{{ object.generators|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'other_companies_power' }}</dt>
<dd class="col-sm-6">
{{ object.other_companies_power|yesno|title }}
{{ object.other_companies_power|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'nonstandard_equipment_power' }}</dt>
<dd class="col-sm-6">
{{ object.nonstandard_equipment_power|yesno|title }}
{{ object.nonstandard_equipment_power|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'multiple_electrical_environments' }}</dt>
<dd class="col-sm-6">
{{ object.multiple_electrical_environments|yesno|title }}
{{ object.multiple_electrical_environments|yesnoi:'invert' }}
</dd>
<dt class="col-12">{{ object|help_text:'power_notes' }}</dt>
<dd class="col-12">
@@ -84,7 +85,7 @@
<dl class="row">
<dt class="col-sm-6">{{ object|help_text:'noise_monitoring' }}</dt>
<dd class="col-sm-6">
{{ object.noise_monitoring|yesno|title }}
{{ object.noise_monitoring|yesnoi:'invert' }}
</dd>
<dt class="col-12">{{ object|help_text:'sound_notes' }}</dt>
<dd class="col-12">
@@ -99,27 +100,27 @@
<dl class="row">
<dt class="col-sm-6">{{ object|help_text:'known_venue' }}</dt>
<dd class="col-sm-6">
{{ object.known_venue|yesno|title }}
{{ object.known_venue|yesnoi }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'safe_loading'|safe }}</dt>
<dd class="col-sm-6">
{{ object.safe_loading.name|yesno|title }}
{{ object.safe_loading.name|yesnoi }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'safe_storage' }}</dt>
<dd class="col-sm-6">
{{ object.safe_storage|yesno|title }}
{{ object.safe_storage|yesnoi }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'area_outside_of_control' }}</dt>
<dd class="col-sm-6">
{{ object.area_outside_of_control|yesno|title }}
{{ object.area_outside_of_control|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'barrier_required' }}</dt>
<dd class="col-sm-6">
{{ object.barrier_required|yesno|title }}
{{ object.barrier_required|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'nonstandard_emergency_procedure' }}</dt>
<dd class="col-sm-6">
{{ object.nonstandard_emergency_procedure|yesno|title }}
{{ object.nonstandard_emergency_procedure|yesnoi:'invert' }}
</dd>
</dl>
</div>
@@ -130,7 +131,7 @@
<dl class="row">
<dt class="col-sm-6">{{ object|help_text:'special_structures' }}</dt>
<dd class="col-sm-6">
{{ object.special_structures|yesno|title }}
{{ object.special_structures|yesnoi:'invert' }}
</dd>
<dt class="col-sm-6">{{ object|help_text:'persons_responsible_structures' }}</dt>
<dd class="col-sm-6">
@@ -138,7 +139,7 @@
</dd>
<dt class="col-sm-6">{{ object|help_text:'suspended_structures' }}</dt>
<dd class="col-sm-6">
{{ object.suspended_structures|yesno|title }}
{{ object.suspended_structures|yesnoi:'invert' }}
</dd>
</dl>
</div>

View File

@@ -8,6 +8,7 @@ from django.utils.safestring import SafeData, mark_safe
from django.utils.html import escape
from RIGS import models
import json
from django.template.defaultfilters import yesno, title
register = template.Library()
@@ -115,6 +116,8 @@ def orderby(request, field, attr):
return dict_.urlencode()
# Used for accessing outside of a form, i.e. in detail views of RiskAssessment and EventChecklist
@register.filter
def help_text(obj, field):
if hasattr(obj, '_meta'):
@@ -149,3 +152,16 @@ def next(alist, current_index):
return alist[int(current_index) + 1] # access the next element
except BaseException:
return '' # return empty string in case of exception
@register.filter(needs_autoescape=True)
def yesnoi(boolean, invert=False, autoescape=True):
value = yesno(boolean)
value = title(value)
if invert:
boolean = not boolean
if boolean:
value += ' <span class="fas fa-check-square" style="color: green;"></span>'
else:
value += ' <span class="fas fa-exclamation" style="color: red;"></span>'
return mark_safe(value)