Improvements to generic lists

This commit is contained in:
2020-03-22 12:46:52 +00:00
parent 41b0387e49
commit ee7ba3ea19
13 changed files with 112 additions and 130 deletions

View File

@@ -1,5 +1,5 @@
<div class="table-responsive">
<table class="table">
<table class="table mb-0">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>

View File

@@ -2,9 +2,9 @@
{% block title %}RIGS{% endblock %}
{% block content %}
<h1>R<small class="text-muted">ig</small> I<small class="text-muted">nformation</small class="text-muted"> G<small class="text-muted">athering</small> S<small class="text-muted">ystem</small></h1>
<h4 class="list-group-item-heading">Welcome back {{ user.get_full_name }}, there are {{ rig_count }} rigs coming up.</h4>
<div class="row">
<h1 class="col-sm-12 pb-3">R<small class="text-muted">ig</small> I<small class="text-muted">nformation</small class="text-muted"> G<small class="text-muted">athering</small> S<small class="text-muted">ystem</small></h1>
<h4 class="col-sm-12 pb-3">Welcome back {{ user.get_full_name }}, there are {{ rig_count }} rigs coming up.</h4>
<div class="col-sm">
<div class="card">
<div class="card-header">

View File

@@ -4,10 +4,8 @@
{% block title %}Organisations{% endblock %}
{% block content %}
<div class="row">
<div class="col-sm-10">
<h3>Organisations</h3>
</div>
</div>
{% include 'partials/generic_list.html' with edit="organisation_update" detail="organisation_detail" create="organisation_create" union_account=True %}
<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

@@ -18,52 +18,47 @@
</div>
{% endif %}
<div class="col-sm">
<div class="card card-info">
<div class="card-header">Person Details</div>
<div class="card border-info">
<div class="card-header bg-info">Person Details</div>
<div class="card-body">
<dl class="dl-horizontal">
<dt>Name</dt>
<dl class="row">
<dt class="col-6">Name</dt>
<dd>{{ object.name }}</dd>
<dt>Phone</dt>
<dt class="col-6">Phone</dt>
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
<dt>Email</dt>
<dt class="col-6">Email</dt>
<dd><a href="mailto:{{ object.email }}"><span class="overflow-ellipsis">{{ object.email }}</span></a></dd>
<dt>Address</dt>
<dt class="col-6">Address</dt>
<dd>{{ object.address|linebreaksbr }}</dd>
<dt>Notes</dt>
<dd>{{ object.notes|linebreaksbr }}</dd>
<dt class="col-12">Notes</dt>
<dd class="col-12">{{ object.notes|linebreaksbr }}</dd>
</dl>
</div>
</div>
</div>
<div class="col-sm">
<div class="card card-default">
<div class="card">
<div class="card-header">Associated Organisations</div>
<div class="card-body">
<div class="list-group">
{% for organisation,count in object.organisations %}
<a class="list-group-item" href="{% url 'organisation_detail' organisation.pk %}">{{ organisation.pk|stringformat:"05d" }} | {{ organisation.name }} <span class="badge" title="{{count}} events with {{object.name}} for {{organisation.name}}">{{count}}</span></a>
{% endfor %}
</div>
</div>
<ul class="list-group list-group-flush">
{% for organisation,count in object.organisations %}
<a class="list-group-item list-group-item-action" href="{% url 'organisation_detail' organisation.pk %}">{{ organisation.pk|stringformat:"05d" }} | {{ organisation.name }} <span class="badge badge-secondary" title="{{count}} events with {{object.name}} for {{organisation.name}}">{{count}}</span></a>
{% endfor %}
</ul>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-sm-12">
<div class="card card-default">
<div class="card">
<div class="card-header">Associated Events</div>
<div class="card-body">
{% with object.latest_events as events %}
{% include 'event_table.html' %}
{% endwith %}
</div>
{% with object.latest_events as events %}
{% include 'event_table.html' %}
{% endwith %}
</div>
</div>
</div>
@@ -82,16 +77,16 @@
{% if request.is_ajax %}
{% block footer %}
<div class="row">
<div class="col-sm-12 text-right">
<div class="btn-group btn-page">
<a href="{% url 'person_detail' object.pk %}" class="btn btn-primary"><span
class="fas fa-eye"></span> Open Page</a>
<a href="{% url 'person_update' object.pk %}" class="btn btn-light"><span
class="fas fa-user-edit"></span> Edit</a>
</div>
{% include 'partials/last_edited.html' with target="person_history" %}
<div class="row">
<div class="col-sm-12">
<div class="btn-group btn-page">
<a href="{% url 'person_detail' object.pk %}" class="btn btn-primary"><span
class="fas fa-eye"></span> Open Page</a>
<a href="{% url 'person_update' object.pk %}" class="btn btn-light"><span
class="fas fa-user-edit"></span> Edit</a>
</div>
{% include 'partials/last_edited.html' with target="person_history" %}
</div>
</div>
{% endblock %}
{% endif %}

View File

@@ -1,16 +1,10 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% load widget_tweaks %}
{% load paginator from filters %}
{% load url_replace from filters %}
{% load orderby from filters %}
{% block title %}People{% endblock %}
{% block content %}
<div class="row">
<div class="col-sm-10">
<h3>People</h3>
</div>
</div>
{% include 'partials/generic_list.html' with edit="person_update" detail="person_detail" create="person_create" %}
<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

@@ -3,14 +3,14 @@
{% block title %}Rigboard{% endblock %}
{% block content %}
<h1>Rigboard</h1>
{% if perms.RIGS.add_event %}
<a href="{% url 'event_create' %}" class="btn btn-success my-3 float-right">New <i class="fas fa-plus"></i></a>
{% endif %}
<div class="d-none d-md-block">
{% include 'event_table.html' %}
</div>
<div class="d-xs-block d-sm-block d-md-none">
{% include 'event_table_mobile.html' %}
</div>
<h1>Rigboard</h1>
{% if perms.RIGS.add_event %}
<a href="{% url 'event_create' %}" class="btn btn-success my-3 float-right">New <i class="fas fa-plus"></i></a>
{% endif %}
<div class="d-none d-md-block">
{% include 'event_table.html' %}
</div>
<div class="d-xs-block d-sm-block d-md-none">
{% include 'event_table_mobile.html' %}
</div>
{% endblock %}

View File

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

View File

@@ -106,7 +106,7 @@ urlpatterns = [
path('invoice/<int:pk>/delete/', permission_required_with_403('RIGS.change_invoice')(finance.InvoiceDelete.as_view()),
name='invoice_delete'),
path('invoice/(<int:pk>/history/', permission_required_with_403('RIGS.view_invoice')(versioning.VersionHistory.as_view()),
name='invoice_history', kwargs={'model': models.Invoice}),
name='invoice_history', kwargs={'model': models.Invoice}),
path('payment/create/', permission_required_with_403('RIGS.add_payment')(finance.PaymentCreate.as_view()),
name='payment_create'),

View File

@@ -104,6 +104,7 @@ class PersonDetail(generic.DetailView):
class PersonCreate(generic.CreateView):
template_name = 'person_form.html'
model = models.Person
fields = ['name', 'phone', 'email', 'address', 'notes']
@@ -121,6 +122,7 @@ class PersonCreate(generic.CreateView):
class PersonUpdate(generic.UpdateView):
template_name = 'person_form.html'
model = models.Person
fields = ['name', 'phone', 'email', 'address', 'notes']

View File

@@ -4,11 +4,8 @@
{% load widget_tweaks %}
{% block content %}
<div class="page-header">
<h1>Supplier List</h1>
<div class="row">
<h3>Suppliers</h3>
</div>
{% include 'partials/generic_list.html' with edit="supplier_update" detail="supplier_detail" create="supplier_create" %}
{% endblock %}

View File

@@ -1,12 +1,8 @@
{% load url_replace from filters %}
{% load orderby from filters %}
{% load paginator from filters %}
<div class="row justify-content-end">
<a href="{% url create %}" class="btn btn-success">New <span
class="fas fa-plus"></span></a>
</div>
<div class="row justify-content-end">
<form class="form-inline py-3">
<div class="row justify-content-end py-3">
<form class="form-inline pr-3">
{% csrf_token %}
<div class="input-group pull-right">
<input type="search" name="query" placeholder="Search" value="{{ request.GET.query }}"
@@ -14,51 +10,57 @@
<span class="input-group-append"><button type="submit" class="btn btn-primary" id="id_search">Search</button></span>
</div>
</form>
<a href="{% url create %}" class="btn btn-success">New <span
class="fas fa-plus"></span></a>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name<a href="?{% orderby request 'orderBy' 'name' %}"><span class="caret"></span></a></td>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">Notes</th>
{% if union_account %} {#TODO#}
<th scope="col">Union Account</th>
{% endif %}
<th scope="col">Quick Links</th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr>
<th scope="row">{{ object.pk }}</th>
<td>{{ object.name }}</td>
<td>{{ object.email }}</td>
<td>{% if object.phone %}<a href="tel:{{ object.phone }}">{%endif%}{{ object.phone }}{% if object.phone %}</a>{%endif%}</td>
<td>{{ object.notes|yesno|capfirst }}</td>
{% if union_account %}
<td>{{ object.union_account|yesno|capfirst }}</td>
{% endif %}
<td>
<a href="{% url detail object.pk %}" class="btn btn-primary modal-href">
<i class="fas fa-eye"></i>
</a>
<a href="{% url edit object.pk %}" class="btn btn-secondary"><i
class="fas fa-edit"></i></a>
</td>
</tr>
{% empty %}
<div class="row">
<div class="table-responsive">
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col">Name<a href="?{% orderby request 'orderBy' 'name' %}"><span class="caret"></span></a></td>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">Notes</th>
{% if union_account %} {#TODO#}
<th scope="col">Union Account</th>
{% endif %}
<th scope="col">Quick Links</th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr>
<th scope="row" class="align-middle">{{ object.pk }}</th>
<td class="align-middle">{{ object.name }}</td>
<td class="align-middle">{{ object.email }}</td>
<td class="align-middle">{% if object.phone %}<a href="tel:{{ object.phone }}">{%endif%}{{ object.phone }}{% if object.phone %}</a>{%endif%}</td>
<td class="align-middle">{{ object.notes|yesno|capfirst }}</td>
{% if union_account %}
<td>{{ object.union_account|yesno|capfirst }}</td>
{% endif %}
<td>
<div class="btn-group d-flex" role="group">
<a href="{% url detail object.pk %}" class="btn btn-primary btn-sm modal-href">
<i class="fas fa-eye"></i> View
</a>
<a href="{% url edit object.pk %}" class="btn btn-warning btn-sm"><i
class="fas fa-edit"></i> Edit</a>
</div>
</td>
</tr>
{% empty %}
<tr class="table-warning">
<td colspan="6" class="text-center">Nothing found</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% if is_paginated %}
<div class="row justify-content-center">
{% paginator %}
</div>
<div class="row justify-content-center">
{% paginator %}
</div>
{% endif %}

View File

@@ -1,5 +0,0 @@
<div>
<a href="{% url target object.pk %}" title="View Revision History">
Last edited {{ object.last_edited_at|default:'never' }} by {{ object.last_edited_by.name|default:'System' }}
</a>
</div>

View File

@@ -0,0 +1,5 @@
<div class="pt-2">
<a href="{% url target object.pk %}" title="View Revision History">
Last edited {{ object.last_edited_at|default:'never' }} by {{ object.last_edited_by.name|default:'System' }}
</a>
</div>