Do not use Django 'required' for radio selects

As this requires them to be True, whereas we just need to require that an option be entered.
This commit is contained in:
2020-07-03 17:09:32 +01:00
parent d09f3994fc
commit 2e60c5e7bf
6 changed files with 158 additions and 36 deletions

View File

@@ -7,4 +7,4 @@
<label class="custom-control-label" for="{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
</div>
{% endfor %}
</div>
</div>

View File

@@ -3,7 +3,7 @@
{% load static %}
{% load help_text from filters %}
{% block title %}{% if edit %}Edit{% else %}Create{% endif %} Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}{% endblock %}
{% block title %}{% if edit %}Edit{% else %}Create{% endif %} Risk Assessment for Event N{{ event.pk|stringformat:"05d" }}{% endblock %}
{% block css %}
{{ block.super }}
@@ -29,12 +29,15 @@
{% block content %}
<div class="col-sm-offset-1 col-sm-10">
<h3>{% if edit %}Edit{% else %}Create{% endif %} Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</h3>
<h3>{% if edit %}Edit{% else %}Create{% endif %} Risk Assessment for Event N{{ event.pk|stringformat:"05d" }}</h3>
{% include 'form_errors.html' %}
{% if edit %}
<form method="POST" action="{% url 'ra_edit' pk=object.pk %}">
<form role="form" method="POST" action="{% url 'ra_edit' pk=object.pk %}">
{% else %}
<form role="form" method="POST" action="{% url 'event_ra' pk=event.pk %}">
{% endif %}
<input type="hidden" name="{{ form.event.name }}" id="{{ form.event.id_for_label }}"
value="{{event.pk}}"/>
{% csrf_token %}
<div class="row">
<div class="col-12">

View File

@@ -18,30 +18,33 @@
<thead>
<tr>
<th scope="col">Event</th>
<th scope="col" class="">{{ object_list.0|verbose_name:'nonstandard_equipment'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'nonstandard_use'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'contractors'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'other_companies'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'crew_fatigue'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'general_notes'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'big_power'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'power_mic'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'generators'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'other_companies_power'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'nonstandard_equipment_power'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'multiple_electrical_environments'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'power_notes'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'noise_monitoring'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'sound_notes'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'known_venue'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'safe_loading'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'safe_storage'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'area_outside_of_control'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'nonstandard_emergency_procedure'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'barrier_required'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'special_structures'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'persons_responsible_structures'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'suspended_structures'|title }}</th>
{# mmm hax #}
{% if object_list.0 %}
<th scope="col" class="">{{ object_list.0|verbose_name:'nonstandard_equipment'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'nonstandard_use'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'contractors'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'other_companies'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'crew_fatigue'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'general_notes'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'big_power'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'power_mic'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'generators'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'other_companies_power'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'nonstandard_equipment_power'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'multiple_electrical_environments'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'power_notes'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'noise_monitoring'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'sound_notes'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'known_venue'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'safe_loading'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'safe_storage'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'area_outside_of_control'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'nonstandard_emergency_procedure'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'barrier_required'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'special_structures'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'persons_responsible_structures'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'suspended_structures'|title }}</th>
{% endif %}
</tr>
</thead>
<tbody>
@@ -54,7 +57,7 @@
<td class="{% if object.other_companies%}bg-danger text-white{%endif%}">{{object.other_companies|yesno|title}}</td>
<td class="{% if object.crew_fatigue%}bg-danger text-white{%endif%}">{{object.crew_fatigue|yesno|title}}</td>
<td>{{ object.general_notes|default:'N/A'|linebreaks }}</td>
<td class="{% if object.big_power%}bg-danger text-white{%endif%}">{{object.big_power|yesno|title}}</td>
<td>{{ object.power_mic.name|default:'N/A' }}</td>
<td class="{% if object.generators%}bg-danger text-white{%endif%}">{{object.generators|yesno|title}}</td>
@@ -62,17 +65,17 @@
<td class="{% if object.nonstandard_equipment_power%}bg-danger text-white{%endif%}">{{object.nonstandard_equipment_power|yesno|title}}</td>
<td class="{% if object.multiple_electrical_environments%}bg-danger text-white{%endif%}">{{object.multiple_electrical_environments|yesno|title}}</td>
<td>{{ object.power_notes|default:'N/A'|linebreaks }}</td>
<td class="{% if object.noise_monitoring%}bg-danger text-white{%endif%}">{{object.noise_monitoring|yesno|title}}</td>
<td>{{ object.sound_notes|default:'N/A'|linebreaks }}</td>
<td class="{% if not object.known_venue%}bg-danger text-white{%endif%}">{{object.known_venue|yesno|title}}</td>
<td class="{% if not object.safe_loading%}bg-danger text-white{%endif%}">{{object.safe_loading|yesno|title}}</td>
<td class="{% if object.safe_storage%}bg-danger text-white{%endif%}">{{object.safe_storage|yesno|title}}</td>
<td class="{% if object.area_outside_of_control%}bg-danger text-white{%endif%}">{{object.area_outside_of_control|yesno|title}}</td>
<td class="{% if object.nonstandard_emergency_procedure%}bg-danger text-white{%endif%}">{{object.nonstandard_emergency_procedure|yesno|title}}</td>
<td class="{% if object.barrier_required%}bg-danger text-white{%endif%}">{{object.barrier_required|yesno|title}}</td>
<td class="{% if object.special_structures%}bg-danger text-white{%endif%}">{{object.special_structures|yesno|title}}</td>
<td>{{ object.persons_responsible_structures|default:'N/A'|linebreaks }}</td>
<td class="{% if object.suspended_structures%}bg-danger text-white{%endif%}">{{object.suspended_structures|yesno|title}}</td>