Validation of power reqs

This commit is contained in:
2020-08-30 12:15:04 +01:00
parent bfe80db85e
commit f3c2ce2519
10 changed files with 281 additions and 53 deletions

View File

@@ -91,12 +91,75 @@
</table>
</div>
<div class="card card-default mb-3">
<div class="card-header">Power</div>
<div class="card-header">Power {% if object.medium_event %}<span class="badge badge-warning p-2 my-3">Medium Event</span>{%else%}<span class="badge badge-success p-2 my-3">Small Event</span>{%endif%}</div>
<div class="card-body">
{% if object.medium_event %}
<span class="badge badge-warning p-2 my-3">Medium Event</span>
<dl class="row">
<dt class="col-10">{{ object|help_text:'source_rcd'|safe }}</dt>
<dd class="col-2">
{{ object.source_rcd|yesno|title }}
</dd>
<dt class="col-10">{{ object|help_text:'labelling'|safe }}</dt>
<dd class="col-2">
{{ object.labelling|yesno|title }}
</dd>
<dt class="col-10">{{ object|help_text:'earthing'|safe }}</dt>
<dd class="col-2">
{{ object.earthing|yesno|title }}
</dd>
<dt class="col-10">{{ object|help_text:'pat'|safe }}</dt>
<dd class="col-2">
{{ object.pat|yesno|title }}
</dd>
</dl>
<hr>
<p>Tests at first distro</p>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col" class="text-center">Test</th>
<th scope="col" colspan="3" class="text-center">Value</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" rowspan="2">Voltage<br><small>(cube meter)</small></th>
<th>{{ object|help_text:'fd_voltage_l1' }}</th>
<th>{{ object|help_text:'fd_voltage_l2' }}</th>
<th>{{ object|help_text:'fd_voltage_l3' }}</th>
</tr>
<tr>
<td>{{ object.fd_voltage_l1 }}</td>
<td>{{ object.fd_voltage_l2 }}</td>
<td>{{ object.fd_voltage_l3 }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'fd_phase_rotation'|safe }}</th>
<td colspan="3">{{ object.fd_phase_rotation|yesno|title }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'fd_earth_fault'|safe}}</th>
<td colspan="3">{{ object.fd_earth_fault }}</td>
</tr>
<tr>
<th scope="row">{{ object|help_text:'fd_pssc'}}</th>
<td colspan="3">{{ object.fd_pssc }}</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 }}
</dd>
<dt class="col-10">{{ object|help_text:'public_sockets_tested'|safe }}</dt>
<dd class="col-2">
{{ object.public_sockets_tested|yesno|title }}
</dd>
</dl>
{% include 'partials/ec_power_info.html' %}
{% else %}
<span class="badge badge-success p-2 my-3">Small Event</span>
<dl class="row">
<dt class="col-10">{{ object|help_text:'rcds'|safe }}</dt>
<dd class="col-2">
@@ -119,13 +182,13 @@
</div>
</div>
</div>
</div>
<div class="col-12 text-right">
<a href="{% url 'ec_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
class="hidden-xs">Edit</span></a>
</div>
<div class="col-12 text-right">
{% include 'partials/last_edited.html' with target="eventchecklist_history" %}
<div class="col-12 text-right">
<a href="{% url 'ec_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
class="hidden-xs">Edit</span></a>
</div>
<div class="col-12 text-right">
{% include 'partials/last_edited.html' with target="eventchecklist_history" %}
</div>
</div>
</div>
{% endblock %}

View File

@@ -49,10 +49,14 @@
$('#{{form.medium_event.auto_id}}').prop('checked', true);
$('#small-event').slideUp();
$('#medium-event').slideDown();
//$('#medium-event').find('select,input').attr('required', 'true');
//$('#small-event').find('select,input').removeAttr('required');
} else {
$('#{{form.medium_event.auto_id}}').prop('checked', false);
$('#small-event').slideDown();
$('#medium-event').slideUp();
//('#small-event').find('select,input').attr('required', 'true');
//('#medium-event').find('select,input').removeAttr('required');
}
});
$('button[data-action=add]').on('click', function (event) {
@@ -118,7 +122,7 @@
<label for="{{ form.power_mic.id_for_label }}"
class="col-4 control-label">{{ form.power_mic.help_text }}</label>
<div class="col-8">
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
<select id="{{ form.power_mic.id_for_label }}" name="{{ form.power_mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required="true">
{% if object.power_mic %}
<option value="{{object.power_mic.pk}}" selected="selected">{{ object.power_mic.name }}</option>
{% endif %}
@@ -261,27 +265,24 @@
<div class="card-header">Electrical Checks <small>for Medium TEC Events </small></div>
<div class="card-body">
{% include 'partials/checklist_checkbox.html' with formitem=form.source_rcd %}
{% include 'partials/checklist_checkbox.html' with formitem=form.clear_labelling %}
{% include 'partials/checklist_checkbox.html' with formitem=form.labelling %}
{% include 'partials/checklist_checkbox.html' with formitem=form.earthing %}
{% include 'partials/checklist_checkbox.html' with formitem=form.pat %}
<hr>
<p>Tests at first distro</p>
<table class="table">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Test</th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col" class="text-center">Test</th>
<th scope="col" colspan="3" class="text-center">Value</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" rowspan="2">Voltage<br><small>(cube meter)</small></th>
<th>{{object|help_text:'fd_voltage_l1'}}</th>
<th>{{object|help_text:'fd_voltage_l2'}}</th>
<th>{{object|help_text:'fd_voltage_l3'}}</th>
<th>{{ form.fd_voltage_l1.help_text }}</th>
<th>{{ form.fd_voltage_l2.help_text }}</th>
<th>{{ form.fd_voltage_l3.help_text }}</th>
</tr>
<tr>
<td>{% render_field form.fd_voltage_l1 class+="form-control" %}</td>
@@ -289,15 +290,15 @@
<td>{% render_field form.fd_voltage_l3 class+="form-control" %}</td>
</tr>
<tr>
<th scope="row">{{object|help_text:'fd_phase_rotation'|safe}}</th>
<td colspan="3">{% render_field form.fd_phase_rotation %}</td>
<th scope="row">{{form.fd_phase_rotation.help_text|safe}}</th>
<td colspan="3">{% include 'partials/checklist_checkbox.html' with formitem=form.fd_phase_rotation %}</td>
</tr>
<tr>
<th scope="row">{{object|help_text:'fd_earth_fault'|safe}}</th>
<th scope="row">{{form.fd_earth_fault.help_text|safe}}</th>
<td colspan="3">{% render_field form.fd_earth_fault class+="form-control" %}</td>
</tr>
<tr>
<th scope="row">{{object|help_text:'fd_pssc'|safe}}</th>
<th scope="row">{{form.fd_pssc.help_text|safe}}</th>
<td colspan="3">{% render_field form.fd_pssc class+="form-control" %}</td>
</tr>
</tbody>

View File

@@ -1,6 +1,6 @@
{% load widget_tweaks %}
{% load help_text from filters %}
<div class="form-check">
{% render_field formitem|attr:'required=true' class+="form-check-input" %}
{% render_field formitem class+="form-check-input" %}
<label class="form-check-label" for="{{ formitem.id_for_label }}">{{formitem.help_text|safe}}</label>
</div>

View File

@@ -1,10 +1,12 @@
<label for="{{ formitem.id_for_label }}"
class="col-sm-8 control-label">{{ formitem.help_text|safe }}</label>
<div class="col-4 pb-3">
{% for radio in formitem %}
<div class="custom-control custom-radio">
{{ radio.tag }}
<label class="custom-control-label" for="{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
</div>
{% endfor %}
<div class="row">
<label for="{{ formitem.id_for_label }}"
class="col-8 control-label">{{ formitem.help_text|safe }}</label>
<div class="col-4 pb-3">
{% for radio in formitem %}
<div class="custom-control custom-radio">
{{ radio.tag }}
<label class="custom-control-label" for="{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
</div>
{% endfor %}
</div>
</div>