Fix list templates

TODO: Sensible place to define the 'expected answer' stuff.
This commit is contained in:
2020-09-03 12:38:52 +01:00
parent c1182efa54
commit e602058771
12 changed files with 128 additions and 222 deletions

View File

@@ -1,67 +0,0 @@
{% extends 'base_rigs.html' %}
{% load paginator from filters %}
{% load help_text from filters %}
{% load verbose_name from filters %}
{% block title %}Event Checklist List{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<h2>Event Checklist List</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="table-responsive">
<table class="table mb-0">
<thead>
<tr>
<th scope="col">Event</th>
{# mmm hax #}
{% if object_list.0 %}
<th scope="col" class="">{{ object_list.0|verbose_name:'power_mic'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'vehicles'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'safe_parking'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'safe_packing'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'exits'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'trip_hazard'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'warning_signs'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'ear_plugs'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'hs_location'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'extinguishers_location'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'rcds'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'supply_test'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'earthing'|title }}</th>
<th scope="col">{{ object_list.0|verbose_name:'pat'|title }}</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr>
{# General #}
<th scope="row" class="{% if object.reviewed_by %}bg-success{%endif%}"><a href="{% url 'event_detail' object.event.pk %}">N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</a></th>
<td>{{object.power_mic.name}}</td>
{# Buttons #}
<td>
<a class="btn btn-primary" href="{% url 'ra_detail' object.pk %}">View</a>
{{ object.review_string|safe }}
</td>
</tr>
{% empty %}
<tr class="bg-warning text-dark">
<td colspan="6">No checklists found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% if is_paginated %}
<div class="row justify-content-center">
{% paginator %}
</div>
{% endif %}
{% endblock %}

View File

@@ -25,8 +25,8 @@
<br><span><strong>{{ event.end_date|date:"D d/m/Y" }}</strong></span>
{% endif %}
</td>
<td>{% include 'partials/hs_status.html' with event=event object=event.riskassessment view='ra_detail' edit='ra_edit' create='event_ra' %}</td>
<td>{% include 'partials/hs_status.html' with event=event object=event.eventchecklist view='ec_detail' edit='ec_edit' create='event_ec' %}</td>
<td>{% include 'partials/hs_status.html' with event=event object=event.riskassessment view='ra_detail' edit='ra_edit' create='event_ra' review='ra_review' perm=perms.RIGS.review_riskassessment %}</td>
<td>{% include 'partials/hs_status.html' with event=event object=event.eventchecklist view='ec_detail' edit='ec_edit' create='event_ec' review='ec_review' perm=perms.RIGS.review_eventchecklist %}</td>
</tr>
{% empty %}
<tr class="bg-warning text-dark">

View File

@@ -0,0 +1,57 @@
{% extends 'base_rigs.html' %}
{% load paginator from filters %}
{% load help_text from filters %}
{% load verbose_name from filters %}
{% load get_field from filters %}
{% block title %}{{ title }} List{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<h2>{{title}} List</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="table-responsive">
<table class="table mb-0">
<thead>
<tr>
<th scope="col">Event</th>
{# mmm hax #}
{% for field in fields %}
<th scope="col">{{ object_list.0|verbose_name:field|title }}</th>
{% endfor %}
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr class="{% if object.reviewed_by %}table-success{%endif%}">
{# General #}
<th scope="row"><a href="{% url 'event_detail' object.event.pk %}">{{ object.event }}</a></th>
{% for field in fields %}
<td>{{ object|get_field:field }}</td>
{% endfor %}
{# Buttons #}
<td>
{% include 'partials/hs_status.html' %}
</td>
</tr>
{% empty %}
<tr class="bg-warning">
<td colspan="6">Nothing found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% if is_paginated %}
<div class="row justify-content-center">
{% paginator %}
</div>
{% endif %}
{% endblock %}

View File

@@ -1,12 +1,14 @@
{% load to_class_name from filters %}
{% if object.pk != None %}
{#<span class="badge badge-success my-3"><span class="fas fa-check"></span> Completed</span><br/>#}
<div class="btn-group">
<a href="{% url view object.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> <span class="hidden-xs"> View</span>
<a href="{% url edit object.pk %}" class="btn btn-warning"><span class="fas fa-edit"></span><span class="hidden-xs"> Edit</span></a>
</div>
{{ object.review_string|safe }}
{% else %}
<div class="btn-group">
<a href="{% url view object.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> <span class="hidden-xs"> View</span>
<a href="{% url edit object.pk %}" class="btn btn-warning"><span class="fas fa-edit"></span><span class="hidden-xs"> Edit</span></a>
</div>
{% if object.reviewed_by %}
<span class='badge badge-success py-2'>Reviewed by <a href='{% url 'profile_detail' object.reviewed_by.pk %}'>{{object.reviewed_by}}</a> at {{object.reviewed_at}}</span>
{% elif perm %}
<a class='btn btn-success my-2' href='{% url review object.pk %}'>Mark Reviewed</a>
{% endif %}
{% elif event != None %}
<a href="{% url create event.pk %}" class="btn btn-info"><span class="fas fa-paperclip"></span> <span
class="hidden-xs">Create</span></a>
{% endif %}

View File

@@ -1,105 +0,0 @@
{% extends 'base_rigs.html' %}
{% load paginator from filters %}
{% load help_text from filters %}
{% load verbose_name from filters %}
{% block title %}Risk Assessment List{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<h2>Risk Assessment List</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="table-responsive">
<table class="table mb-0">
<thead>
<tr>
<th scope="col">Event</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>
<th scope="col"></th>
{% endif %}
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr>
{# General #}
<th scope="row" class="{% if object.reviewed_by %}bg-success{%endif%}"><a href="{% url 'event_detail' object.event.pk %}">N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</a></th>
<td class="{% if object.nonstandard_equipment%}bg-danger text-white{%endif%}">{{object.nonstandard_equipment|yesno|title}}</td>
<td class="{% if object.nonstandard_use%}bg-danger text-white{%endif%}">{{object.nonstandard_use|yesno|title}}</td>
<td class="{% if object.contractors%}bg-danger text-white{%endif%}">{{object.contractors|yesno|title}}</td>
<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><span class="text-truncate d-inline-block">{{ object.general_notes|default:'N/A'|linebreaks }}</span></td>
{# Power #}
<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>
<td class="{% if object.other_companies_power%}bg-danger text-white{%endif%}">{{object.other_companies_power|yesno|title}}</td>
<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><span class="text-truncate d-inline-block">{{ object.power_notes|default:'N/A'|linebreaks }}</span></td>
{# Sound #}
<td class="{% if object.noise_monitoring%}bg-danger text-white{%endif%}">{{object.noise_monitoring|yesno|title}}</td>
<td><span class="text-truncate d-inline-block">{{ object.sound_notes|default:'N/A'|linebreaks }}</span></td>
{# Venue #}
<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>
{# Rigging #}
<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>
{# Buttons #}
<td>
<a class="btn btn-primary" href="{% url 'ra_detail' object.pk %}">View</a>
{{ object.review_string|safe }}
</td>
</tr>
{% empty %}
<tr class="bg-warning text-dark">
<td colspan="6">No risk assessments found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% if is_paginated %}
<div class="row justify-content-center">
{% paginator %}
</div>
{% endif %}
{% endblock %}