Better approach to generic list templates + other deduplication

This commit is contained in:
2020-10-08 22:54:30 +01:00
parent af7d3c4070
commit 3903481b3d
33 changed files with 252 additions and 309 deletions

View File

@@ -1,7 +1,6 @@
{% extends 'base_rigs.html' %}
{% load static %}
{% block title %}Calendar{% endblock %}
{% block css %}

View File

@@ -1,10 +1,9 @@
{% extends 'base_rigs.html' %}
{% load paginator from filters %}
{% load get_list from filters %}
{% load button from filters %}
{% load static %}
{% block title %}Event Archive{% endblock %}
{% block css %}
<link rel="stylesheet" href="{% static 'css/bootstrap-select.css' %}"/>
{% endblock %}
@@ -14,50 +13,44 @@
{% endblock %}
{% block content %}
<div class="row">
<div class="col-sm-12">
<h2>Event Archive</h2>
</div>
<div class="col-sm-12 py-2">
<form class="form-inline" method="GET">
<div class="input-group mx-2">
<div class="input-group-prepend">
<span class="input-group-text">Start</span>
</div>
<input type="date" name="start" id="start" value="{{ start|default_if_none:'' }}" placeholder="Start" class="form-control" />
<div class="row">
<div class="col-sm-12 py-2">
<form class="form-inline" method="GET">
<div class="input-group mx-2">
<div class="input-group-prepend">
<span class="input-group-text">Start</span>
</div>
<div class="input-group mx-2">
<div class="input-group-prepend">
<span class="input-group-text">End</span>
</div>
<input type="date" name="end" id="end" value="{{ end|default_if_none:'' }}" placeholder="End" class="form-control" />
<input type="date" name="start" id="start" value="{{ start|default_if_none:'' }}" placeholder="Start" class="form-control" />
</div>
<div class="input-group mx-2">
<div class="input-group-prepend">
<span class="input-group-text">End</span>
</div>
<div class="input-group mx-2">
<div class="input-group-prepend">
<span class="input-group-text">Keyword</span>
</div>
<input type="search" name="q" placeholder="Keyword" value="{{ request.GET.q }}" class="form-control" />
<input type="date" name="end" id="end" value="{{ end|default_if_none:'' }}" placeholder="End" class="form-control" />
</div>
<div class="input-group mx-2">
<div class="input-group-prepend">
<span class="input-group-text">Keyword</span>
</div>
<select class="selectpicker pr-3" multiple data-actions-box="true" data-none-selected-text="Status" data-actions-box="true" id="status" name="status">
{% for status in statuses %}
<option value="{{status.0}}" {% if status.0|safe in request.GET|get_list:'status' %}selected=""{% endif %}>{{status.1}}</option>
{% endfor %}
</select>
<input type="submit" class="btn btn-primary" value="Search"/>
</form>
</div>
<input type="search" name="q" placeholder="Keyword" value="{{ request.GET.q }}" class="form-control" />
</div>
<select class="selectpicker pr-3" multiple data-actions-box="true" data-none-selected-text="Status" data-actions-box="true" id="status" name="status">
{% for status in statuses %}
<option value="{{status.0}}" {% if status.0|safe in request.GET|get_list:'status' %}selected=""{% endif %}>{{status.1}}</option>
{% endfor %}
</select>
{% button 'search' %}
</form>
</div>
<div class="row">
<div class="col-sm-12">
{% with object_list as events %}
{% include 'event_table.html' %}
{% endwith %}
</div>
</div>
<div class="row">
<div class="col-sm-12">
{% with object_list as events %}
{% include 'partials/event_table.html' %}
{% endwith %}
</div>
</div>
{% paginator %}
{% if is_paginated %}
<div class="row justify-content-center pt-3">
{% paginator %}
</div>
{% endif %}
{% endblock %}

View File

@@ -1,17 +1,17 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% 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 %}
{% load button from filters %}
{% block content %}
<div class="row py-3">
<div class="col-12">
<h3>Event Checklist for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</h3>
<div class="row">
<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 class="col-12 text-right my-3">
{% button 'edit' url='ec_edit' pk=object.pk %}
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
</div>
</div>
<div class="row">
@@ -22,7 +22,7 @@
<dl class="row">
<dt class="col-6">{{ object|help_text:'power_mic' }}</dt>
<dd class="col-6">
{{ object.power_mic.name }}
<a href="{% url 'profile_detail' object.power_mic.pk %}">{{ object.power_mic.name }}</a>
</dd>
</dl>
<p>List vehicles and their drivers</p>
@@ -230,10 +230,9 @@
</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>
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
{{ object.review_string|safe }}
{% button 'edit' url='ec_edit' pk=object.pk %}
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
</div>
<div class="col-12 text-right">
{% include 'partials/last_edited.html' with target="eventchecklist_history" %}

View File

@@ -4,12 +4,6 @@
{% load static %}
{% load multiply from filters %}
{% block title %}
{% if object.pk %}
Event {% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %}
{% else %}New Event{% endif %}
{% endblock %}
{% block css %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'css/bootstrap-select.css' %}"/>
@@ -131,17 +125,6 @@
<form class="form-horizontal itemised_form" role="form" method="POST">
{% csrf_token %}
<div class="row">
<div class="col-sm-12">
<h2>
{% if duplicate %}
Duplicate of Event N{{ object.pk|stringformat:"05d" }}
{% elif object.pk %}
Event N{{ object.pk|stringformat:"05d" }}
{% else %}
New Event
{% endif %}
</h2>
</div>
<div class="col-12">
{% include 'form_errors.html' %}
</div>

View File

@@ -2,8 +2,6 @@
{% load paginator from filters %}
{% load button from filters %}
{% block title %}H&S Overview{% endblock %}
{% block content %}
<div class="table-responsive">
<table class="table mb-0">

View File

@@ -1,11 +0,0 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% load widget_tweaks %}
{% block title %}Organisations{% endblock %}
{% block content %}
<div class="row">
<h3>Organisations</h3>
</div>
{% include 'partials/generic_list.html' with edit="organisation_update" detail="organisation_detail" create="organisation_create" union_account=True %}
{% endblock %}

View File

@@ -2,7 +2,7 @@
<div class="col-sm-12 py-3">
<div class="card">
<div class="card-header">Associated Events</div>
{% include 'event_table.html' with events=object.latest_events %}
{% include 'partials/event_table.html' with events=object.latest_events %}
</div>
</div>
</div>

View File

@@ -4,11 +4,7 @@
{% button 'view' view object.pk %}
{% button 'edit' edit object.pk %}
</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 %}
{% include 'partials/review_status.html' %}
{% 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>

View File

@@ -0,0 +1,7 @@
{% 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>
{% else %}
Not reviewed
{% endif %}

View File

@@ -1,10 +0,0 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% block title %}People{% endblock %}
{% block content %}
<div class="row">
<h3>People</h3>
</div>
{% include 'partials/generic_list.html' with edit="person_update" detail="person_detail" create="person_create" %}
{% endblock %}

View File

@@ -1,22 +1,18 @@
{% extends 'base_rigs.html' %}
{% load button from filters %}
{% block title %}Rigboard{% endblock %}
{% block content %}
<h1>Rigboard</h1>
<div class="row align-items-center justify-content-between py-2">
<div class="col-sm-12 col-md">
Key: <span class="table-success mr-1 px-2">Ready</span><span class="table-warning mr-1 px-2">Action Required</span><span class="table-danger mr-1 px-2">Needs MIC</span><span class="table-secondary mr-1 px-2">Cancelled</span><span class="table-info px-2">Non-Rig</span>
</div>
{% if perms.RIGS.add_event %}
<div class="col text-right">
{% button 'new' 'event_create' None %}
{% button 'new' 'event_create' %}
</div>
{% endif %}
</div>
{% include 'event_table.html' %}
{% include 'partials/event_table.html' %}
{% endblock %}

View File

@@ -1,10 +0,0 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% block title %}Venues{% endblock %}
{% block content %}
<div class="row">
<h3>Venues</h3>
</div>
{% include 'partials/generic_list.html' with edit="venue_update" detail="venue_detail" create="venue_create" %}
{% endblock %}