From 3903481b3dcfde6f90901a5bf7db272e95a5c2b6 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Thu, 8 Oct 2020 22:54:30 +0100 Subject: [PATCH] Better approach to generic list templates + other deduplication --- PyRIGS/views.py | 8 ++ RIGS/hs.py | 22 +++--- RIGS/models.py | 36 +-------- RIGS/rigboard.py | 5 ++ RIGS/templates/calendar.html | 1 - RIGS/templates/event_archive.html | 77 +++++++++---------- RIGS/templates/event_checklist_detail.html | 19 +++-- RIGS/templates/event_form.html | 17 ---- RIGS/templates/hs_list.html | 2 - RIGS/templates/organisation_list.html | 11 --- .../templates/partials/associated_events.html | 2 +- .../templates/{ => partials}/event_table.html | 0 RIGS/templates/partials/hs_status.html | 6 +- RIGS/templates/partials/review_status.html | 7 ++ RIGS/templates/person_list.html | 10 --- RIGS/templates/rigboard.html | 8 +- RIGS/templates/venue_list.html | 10 --- RIGS/templatetags/filters.py | 22 +++--- RIGS/views.py | 25 +++++- assets/templates/asset_list.html | 53 ++++++------- assets/templates/base_assets.html | 4 +- .../templates/partials/asset_list_table.html | 7 +- assets/templates/supplier_list.html | 11 --- assets/views.py | 11 ++- templates/base.html | 4 +- templates/button.html | 7 -- templates/generic_list.html | 70 +++++++++++++++++ templates/index.html | 2 +- templates/pagination.html | 16 ++-- templates/partials/button.html | 7 ++ templates/partials/generic_list.html | 67 ---------------- templates/partials/search.html | 6 +- users/templates/partials/navbar_user.html | 8 +- 33 files changed, 252 insertions(+), 309 deletions(-) delete mode 100644 RIGS/templates/organisation_list.html rename RIGS/templates/{ => partials}/event_table.html (100%) create mode 100644 RIGS/templates/partials/review_status.html delete mode 100644 RIGS/templates/person_list.html delete mode 100644 RIGS/templates/venue_list.html delete mode 100644 assets/templates/supplier_list.html delete mode 100644 templates/button.html create mode 100644 templates/generic_list.html create mode 100644 templates/partials/button.html delete mode 100644 templates/partials/generic_list.html diff --git a/PyRIGS/views.py b/PyRIGS/views.py index f258e236..3899daf2 100644 --- a/PyRIGS/views.py +++ b/PyRIGS/views.py @@ -151,8 +151,16 @@ class SecureAPIRequest(generic.View): class GenericListView(generic.ListView): + template_name = 'generic_list.html' paginate_by = 20 + def get_context_data(self, **kwargs): + context = super(generic.ListView, self).get_context_data(**kwargs) + context['page_title'] = self.model.__name__ + "s" + if self.request.is_ajax(): + context['override'] = "base_ajax.html" + return context + def get_queryset(self): q = self.request.GET.get('q', "") diff --git a/RIGS/hs.py b/RIGS/hs.py index 230a43ca..85691cc3 100644 --- a/RIGS/hs.py +++ b/RIGS/hs.py @@ -100,6 +100,11 @@ class EventChecklistDetail(generic.DetailView): model = models.EventChecklist template_name = 'event_checklist_detail.html' + def get_context_data(self, **kwargs): + context = super(EventChecklistDetail, self).get_context_data(**kwargs) + context['page_title'] = "Event Checklist for Event {} {}".format(self.object.event.display_id, self.object.event.name) + return context + class EventChecklistEdit(generic.UpdateView): model = models.EventChecklist @@ -127,18 +132,6 @@ class EventChecklistCreate(generic.CreateView): template_name = 'event_checklist_form.html' form_class = forms.EventChecklistForm - """def get(self, *args, **kwargs): - epk = kwargs.get('pk') - event = models.Event.objects.get(pk=epk) - - # Check if RA exists - ra = models.EventChecklist.objects.filter(event=event).first() - - if ra is not None: - return HttpResponseRedirect(reverse_lazy('ec_edit', kwargs={'pk': ra.pk})) - - return super(EventChecklistCreate, self).get(self)""" - def get_form(self, **kwargs): form = super(EventChecklistCreate, self).get_form(**kwargs) epk = self.kwargs.get('pk') @@ -192,3 +185,8 @@ class HSList(generic.ListView): def get_queryset(self): return models.Event.objects.all().order_by('-start_date') + + def get_context_data(self, **kwargs): + context = super(HSList, self).get_context_data(**kwargs) + context['page_title'] = 'H&S Overview' + return context diff --git a/RIGS/models.py b/RIGS/models.py index 7a2798a5..b814fff2 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -335,7 +335,10 @@ class Event(models.Model, RevisionMixin): @property def display_id(self): - return str("N%05d" % self.pk) + if self.is_rig: + return str("N%05d" % self.pk) + else: + return self.pk # Calculated values """ @@ -670,15 +673,6 @@ class RiskAssessment(models.Model, RevisionMixin): ('review_riskassessment', 'Can review Risk Assessments') ] - """def clean(self): - errdict = {} - for field in RiskAssessment._meta.fields: - if field.__class__ == forms.BooleanField and self.field is None: - errdict[field.name] = ["This field is required"] - - if errdict != {}: # If there was an error when validation - raise ValidationError(errdict)""" - @property def activity_feed_string(self): return str(self.event) @@ -760,28 +754,6 @@ class EventChecklist(models.Model, RevisionMixin): ('review_eventchecklist', 'Can review Event Checklists') ] - """def clean(self): - errdict = {} - - if self.power_mic is None: - errdict["power_mic"] = ["You must select a Power MIC"] - - if self.earthing is None or self.pat is None: - errdict['earthing'] = 'Fill out the electrical checks' - - if self.event_size == 0 and (self.rcds is None or self.supply_test is None): - errdict['rcds'] = 'Fill out the small event electrical checks' - - if self.event_size == 1: - if self.source_rcd is None or self.labelling is None or self.all_rcds_tested is None or self.public_sockets_tested is None: - errdict['source_rcd'] = 'Fill out the medium event electrical checks' - - if self.w1_description is None or self.w1_polarity is None or self.w1_voltage is None or self.w1_earth_fault is None: - errdict['w1_description'] = 'Fully complete at least the first worst case point' - - if errdict != {}: # If there was an error when validation - raise ValidationError(errdict)""" - @property def activity_feed_string(self): return str(self.event) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 706bdb91..3d106cc9 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -44,6 +44,7 @@ class RigboardIndex(generic.TemplateView): # call out method to get current events context['events'] = models.Event.objects.current_events() + context['page_title'] = "Rigboard" return context @@ -91,6 +92,7 @@ class EventCreate(generic.CreateView): def get_context_data(self, **kwargs): context = super(EventCreate, self).get_context_data(**kwargs) + context['page_title'] = "New Event" context['edit'] = True context['currentVAT'] = models.VatRate.objects.current_rate() @@ -116,6 +118,7 @@ class EventUpdate(generic.UpdateView): def get_context_data(self, **kwargs): context = super(EventUpdate, self).get_context_data(**kwargs) + context['page_title'] = "Event {}".format(self.object.display_id) context['edit'] = True form = context['form'] @@ -170,6 +173,7 @@ class EventDuplicate(EventUpdate): def get_context_data(self, **kwargs): context = super(EventDuplicate, self).get_context_data(**kwargs) + context['page_title'] = "Duplicate of Event {}".format(self.object.display_id) context["duplicate"] = True return context @@ -225,6 +229,7 @@ class EventArchive(generic.ListView): context['start'] = self.request.GET.get('start', None) context['end'] = self.request.GET.get('end', datetime.date.today().strftime('%Y-%m-%d')) context['statuses'] = models.Event.EVENT_STATUS_CHOICES + context['page_title'] = 'Event Archive' return context def get_queryset(self): diff --git a/RIGS/templates/calendar.html b/RIGS/templates/calendar.html index 25a33931..fdc8aca2 100644 --- a/RIGS/templates/calendar.html +++ b/RIGS/templates/calendar.html @@ -1,7 +1,6 @@ {% extends 'base_rigs.html' %} {% load static %} - {% block title %}Calendar{% endblock %} {% block css %} diff --git a/RIGS/templates/event_archive.html b/RIGS/templates/event_archive.html index a17ef39e..67bc8244 100644 --- a/RIGS/templates/event_archive.html +++ b/RIGS/templates/event_archive.html @@ -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 %} {% endblock %} @@ -14,50 +13,44 @@ {% endblock %} {% block content %} -
-
-

Event Archive

-
-
-
-
-
- Start -
- +
+
+ +
+
+ Start
-
-
- End -
- + +
+
+
+ End
-
-
- Keyword -
- + +
+
+
+ Keyword
- - - -
+ +
+ + {% button 'search' %} +
-
-
- {% with object_list as events %} - {% include 'event_table.html' %} - {% endwith %} -
+
+
+
+ {% with object_list as events %} + {% include 'partials/event_table.html' %} + {% endwith %}
+
+ +{% paginator %} - {% if is_paginated %} -
- {% paginator %} -
- {% endif %} {% endblock %} diff --git a/RIGS/templates/event_checklist_detail.html b/RIGS/templates/event_checklist_detail.html index 46708e03..27f271ec 100644 --- a/RIGS/templates/event_checklist_detail.html +++ b/RIGS/templates/event_checklist_detail.html @@ -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 %}
-

Event Checklist for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}

-
- +
+ {% 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' %}
@@ -22,7 +22,7 @@
{{ object|help_text:'power_mic' }}
- {{ object.power_mic.name }} + {{ object.power_mic.name }}

List vehicles and their drivers

@@ -230,10 +230,9 @@
- - View Event - {{ 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' %}
{% include 'partials/last_edited.html' with target="eventchecklist_history" %} diff --git a/RIGS/templates/event_form.html b/RIGS/templates/event_form.html index 0f7196e6..e8275641 100644 --- a/RIGS/templates/event_form.html +++ b/RIGS/templates/event_form.html @@ -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 }} @@ -131,17 +125,6 @@
{% csrf_token %}
-
-

- {% if duplicate %} - Duplicate of Event N{{ object.pk|stringformat:"05d" }} - {% elif object.pk %} - Event N{{ object.pk|stringformat:"05d" }} - {% else %} - New Event - {% endif %} -

-
{% include 'form_errors.html' %}
diff --git a/RIGS/templates/hs_list.html b/RIGS/templates/hs_list.html index cb3755e0..173484df 100644 --- a/RIGS/templates/hs_list.html +++ b/RIGS/templates/hs_list.html @@ -2,8 +2,6 @@ {% load paginator from filters %} {% load button from filters %} -{% block title %}H&S Overview{% endblock %} - {% block content %}
diff --git a/RIGS/templates/organisation_list.html b/RIGS/templates/organisation_list.html deleted file mode 100644 index ca7290e7..00000000 --- a/RIGS/templates/organisation_list.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %} -{% load widget_tweaks %} - -{% block title %}Organisations{% endblock %} - -{% block content %} -
-

Organisations

-
-{% include 'partials/generic_list.html' with edit="organisation_update" detail="organisation_detail" create="organisation_create" union_account=True %} -{% endblock %} diff --git a/RIGS/templates/partials/associated_events.html b/RIGS/templates/partials/associated_events.html index 7334235d..87fe5f92 100644 --- a/RIGS/templates/partials/associated_events.html +++ b/RIGS/templates/partials/associated_events.html @@ -2,7 +2,7 @@
Associated Events
- {% include 'event_table.html' with events=object.latest_events %} + {% include 'partials/event_table.html' with events=object.latest_events %}
diff --git a/RIGS/templates/event_table.html b/RIGS/templates/partials/event_table.html similarity index 100% rename from RIGS/templates/event_table.html rename to RIGS/templates/partials/event_table.html diff --git a/RIGS/templates/partials/hs_status.html b/RIGS/templates/partials/hs_status.html index c699fa97..c02d59c2 100644 --- a/RIGS/templates/partials/hs_status.html +++ b/RIGS/templates/partials/hs_status.html @@ -4,11 +4,7 @@ {% button 'view' view object.pk %} {% button 'edit' edit object.pk %} - {% if object.reviewed_by %} - Reviewed by {{object.reviewed_by}} at {{object.reviewed_at}} - {% elif perm %} - Mark Reviewed - {% endif %} + {% include 'partials/review_status.html' %} {% elif event != None %} diff --git a/RIGS/templates/partials/review_status.html b/RIGS/templates/partials/review_status.html new file mode 100644 index 00000000..5bb9a0b0 --- /dev/null +++ b/RIGS/templates/partials/review_status.html @@ -0,0 +1,7 @@ +{% if object.reviewed_by %} +Reviewed by {{object.reviewed_by}} at {{object.reviewed_at}} +{% elif perm %} +Mark Reviewed +{% else %} +Not reviewed +{% endif %} diff --git a/RIGS/templates/person_list.html b/RIGS/templates/person_list.html deleted file mode 100644 index 56667863..00000000 --- a/RIGS/templates/person_list.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %} - -{% block title %}People{% endblock %} - -{% block content %} -
-

People

-
-{% include 'partials/generic_list.html' with edit="person_update" detail="person_detail" create="person_create" %} -{% endblock %} diff --git a/RIGS/templates/rigboard.html b/RIGS/templates/rigboard.html index c903118c..5e85a185 100644 --- a/RIGS/templates/rigboard.html +++ b/RIGS/templates/rigboard.html @@ -1,22 +1,18 @@ {% extends 'base_rigs.html' %} {% load button from filters %} -{% block title %}Rigboard{% endblock %} - {% block content %} -

Rigboard

-
Key: ReadyAction RequiredNeeds MICCancelledNon-Rig
{% if perms.RIGS.add_event %}
- {% button 'new' 'event_create' None %} + {% button 'new' 'event_create' %}
{% endif %}
-{% include 'event_table.html' %} +{% include 'partials/event_table.html' %} {% endblock %} diff --git a/RIGS/templates/venue_list.html b/RIGS/templates/venue_list.html deleted file mode 100644 index 088248ef..00000000 --- a/RIGS/templates/venue_list.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %} - -{% block title %}Venues{% endblock %} - -{% block content %} -
-

Venues

-
-{% include 'partials/generic_list.html' with edit="venue_update" detail="venue_detail" create="venue_create" %} -{% endblock %} diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index 21aab910..e36664ed 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -188,28 +188,30 @@ def linkornone(attr, namespace, autoescape=True): return "None" -@register.inclusion_tag('button.html') -def button(type, url=None, pk=None, clazz=None, icon=None, text=None): +@register.inclusion_tag('partials/button.html') +def button(type, url=None, pk=None, clazz="", icon=None, text="", id=None, style=None): if type == 'edit': - clazz = "btn-warning" + clazz += " btn-warning " icon = "fa-edit" text = "Edit" elif type == 'print': - clazz = "btn-primary" + clazz += " btn-primary " icon = "fa-print" text = "Print" elif type == 'duplicate': - clazz = "btn-info" + clazz += " btn-info " icon = "fa-copy" text = "Duplicate" elif type == 'view': - clazz = "btn-primary" + clazz += " btn-primary " icon = "fa-eye" - text = "View" + text = "View " + text elif type == 'new': - clazz = "btn-primary" + clazz += " btn-primary " icon = "fa-plus" text = "New" + elif type == 'search': + return {'submit': True, 'class': 'btn-info', 'icon': 'fa-search', 'text': 'Search', 'id': id, 'style': style} elif type == 'submit': - return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save'} - return {'target': url, 'id': pk, 'class': clazz, 'icon': icon, 'text': text} + return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save', 'id': id, 'style': style} + return {'target': url, 'pk': pk, 'class': clazz, 'icon': icon, 'text': text, 'id': id, 'style': style} diff --git a/RIGS/views.py b/RIGS/views.py index ddd78d20..4cb21cc5 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -24,9 +24,16 @@ from PyRIGS.views import GenericListView class PersonList(GenericListView): - template_name = 'person_list.html' model = models.Person + def get_context_data(self, **kwargs): + context = super(PersonList, self).get_context_data(**kwargs) + context['page_title'] = "People" + context['create'] = 'person_create' + context['edit'] = 'person_update' + context['detail'] = 'person_detail' + return context + class PersonDetail(generic.DetailView): template_name = 'person_detail.html' @@ -70,9 +77,15 @@ class PersonUpdate(generic.UpdateView): class OrganisationList(GenericListView): - template_name = 'organisation_list.html' model = models.Organisation + def get_context_data(self, **kwargs): + context = super(OrganisationList, self).get_context_data(**kwargs) + context['create'] = 'organisation_create' + context['edit'] = 'organisation_update' + context['detail'] = 'organisation_detail' + context['union_account'] = True + return context class OrganisationDetail(generic.DetailView): template_name = 'organisation_detail.html' @@ -116,9 +129,15 @@ class OrganisationUpdate(generic.UpdateView): class VenueList(GenericListView): - template_name = "venue_list.html" model = models.Venue + def get_context_data(self, **kwargs): + context = super(VenueList, self).get_context_data(**kwargs) + context['create'] = 'venue_create' + context['edit'] = 'venue_update' + context['detail'] = 'venue_detail' + return context + class VenueDetail(generic.DetailView): template_name = 'venue_detail.html' diff --git a/assets/templates/asset_list.html b/assets/templates/asset_list.html index 3dbaddf4..a13519fc 100644 --- a/assets/templates/asset_list.html +++ b/assets/templates/asset_list.html @@ -1,6 +1,6 @@ {% extends 'base_assets.html' %} -{% block title %}Asset List{% endblock %} {% load paginator from filters %} +{% load button from filters %} {% load widget_tweaks %} {% load static %} @@ -15,34 +15,35 @@ {% endblock %} {% block content %} -

Asset List

-
- -
- {% render_field form.q|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' %} - - -
-
- - {% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %} -
-
- - {% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %} -
- - +
+
+
+
+ {% render_field form.q|add_class:'form-control' placeholder='Enter Asset ID/Desc/Serial' %} + + {% button 'search' id="id_search" style="width: 6em" %} +
+
+ + {% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %} +
+
+ + {% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %} +
+ + +
-
- New +
+
+ {% button 'new' 'asset_create' style="width: 6em" %} +
+
{% include 'partials/asset_list_table.html' %} +
-{% if is_paginated %} -
- {% paginator %} -
-{% endif %} +{% paginator %} {% endblock %} diff --git a/assets/templates/base_assets.html b/assets/templates/base_assets.html index 27e0bd94..9d0a491d 100644 --- a/assets/templates/base_assets.html +++ b/assets/templates/base_assets.html @@ -5,11 +5,11 @@ {% endblock %} {% block titleheader %} - RIGS Assets {% endblock %} {% block titleelements %} +
@@ -21,10 +22,10 @@ Audit {% else %}
- View + {% button 'view' url='asset_detail' pk=item.asset_id clazz="btn-sm" %} {% if perms.assets.change_asset %} - Edit - Duplicate + {% button 'edit' url='asset_detail' pk=item.asset_id clazz="btn-sm" %} + {% button 'duplicate' url='asset_detail' pk=item.asset_id clazz="btn-sm" %} {% endif %}
{% endif %} diff --git a/assets/templates/supplier_list.html b/assets/templates/supplier_list.html deleted file mode 100644 index d0241761..00000000 --- a/assets/templates/supplier_list.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base_assets.html' %} -{% block title %}Supplier List{% endblock %} -{% load paginator from filters %} -{% load widget_tweaks %} - -{% block content %} -
-

Suppliers

-
-{% include 'partials/generic_list.html' with edit="supplier_update" detail="supplier_detail" create="supplier_create" %} -{% endblock %} diff --git a/assets/views.py b/assets/views.py index 3d09ad38..f3d39d96 100644 --- a/assets/views.py +++ b/assets/views.py @@ -64,10 +64,9 @@ class AssetList(LoginRequiredMixin, generic.ListView): def get_context_data(self, **kwargs): context = super(AssetList, self).get_context_data(**kwargs) context["form"] = self.form - context["categories"] = models.AssetCategory.objects.all() - context["statuses"] = models.AssetStatus.objects.all() + context["page_title"] = "Asset List" return context @@ -208,9 +207,15 @@ class AssetAudit(AssetEdit): class SupplierList(GenericListView): model = models.Supplier - template_name = 'supplier_list.html' ordering = ['name'] + def get_context_data(self, **kwargs): + context = super(SupplierList, self).get_context_data(**kwargs) + context['create'] = 'supplier_create' + context['edit'] = 'supplier_update' + context['detail'] = 'supplier_detail' + return context + class SupplierSearch(SupplierList): hide_hidden_status = False diff --git a/templates/base.html b/templates/base.html index 5d119db8..e32c67fd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,7 +7,7 @@ xml:lang="{% firstof LANGUAGE_CODE 'en' %}" lang="{% firstof LANGUAGE_CODE 'en' %}"> - {% block title %}{% endblock %} | Rig Information Gathering System + {{page_title}}{% block title %}{% endblock %} | Rig Information Gathering System @@ -70,7 +70,7 @@ {% endfor %} {% endif %} {% endblock %} - + {% if page_title %}

{{page_title}}

{% endif %} {% block content %}{% endblock %} diff --git a/templates/button.html b/templates/button.html deleted file mode 100644 index 3ff7ff43..00000000 --- a/templates/button.html +++ /dev/null @@ -1,7 +0,0 @@ -{% if submit %} - -{% elif id %} - {{ text }} -{% else %} - {{ text }} -{% endif %} diff --git a/templates/generic_list.html b/templates/generic_list.html new file mode 100644 index 00000000..76946272 --- /dev/null +++ b/templates/generic_list.html @@ -0,0 +1,70 @@ +{% extends override|default:"base_rigs.html" %} +{% load url_replace from filters %} +{% load orderby from filters %} +{% load paginator from filters %} +{% load linkornone from filters %} +{% load button from filters %} + +{% block content %} +
+
+
+ {% csrf_token %} +
+ + {% button 'search' id="id_search" %} +
+ +
+
+
+
+ {% button 'new' url=create %} +
+
+
+
+
+
+ + + + + + {% if union_account %} {#TODO#} + + {% endif %} + + + + + {% for object in object_list %} + + + + + + {% if union_account %} + + {% endif %} + + + {% empty %} + + + + {% endfor %} + +
Name + EmailPhoneNotesUnion AccountQuick Links
{{ object.name }}{{ object.email|linkornone:'mailto' }}{{ object.phone|linkornone:'tel' }}{{ object.notes|yesno|capfirst }}{{ object.union_account|yesno|capfirst }} +
+ {% button 'view' url=detail pk=object.pk clazz="btn-sm modal-href" %} + {% button 'edit' url=edit pk=object.pk clazz="btn-sm modal-href" %} +
+
Nothing found
+
+
+
+{% paginator %} +{% endblock%} diff --git a/templates/index.html b/templates/index.html index e6655883..1e00d5f7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -31,7 +31,7 @@

Quick Links

TEC Forum - TEC Wiki + TEC Wiki {% if perms.RIGS.view_event %} Price List {% endif %} diff --git a/templates/pagination.html b/templates/pagination.html index 957cc24e..1205c102 100644 --- a/templates/pagination.html +++ b/templates/pagination.html @@ -1,14 +1,15 @@ +{% load url_replace from filters %} {% if is_paginated %} - {% load url_replace from filters %} +
+
{% endif %} diff --git a/templates/partials/button.html b/templates/partials/button.html new file mode 100644 index 00000000..7a093e37 --- /dev/null +++ b/templates/partials/button.html @@ -0,0 +1,7 @@ +{% if submit %} + +{% elif pk %} + {{ text }} +{% else %} + {{ text }} +{% endif %} diff --git a/templates/partials/generic_list.html b/templates/partials/generic_list.html deleted file mode 100644 index fd4b916e..00000000 --- a/templates/partials/generic_list.html +++ /dev/null @@ -1,67 +0,0 @@ -{% load url_replace from filters %} -{% load orderby from filters %} -{% load paginator from filters %} -{% load linkornone from filters %} -
-
- {% csrf_token %} -
- - -
-
-
-
- New -
-
-
- - - - - - - {% if union_account %} {#TODO#} - - {% endif %} - - - - - {% for object in object_list %} - - - - - - {% if union_account %} - - {% endif %} - - - {% empty %} - - - - {% endfor %} - -
Name - EmailPhoneNotesUnion AccountQuick Links
{{ object.name }}{{ object.email|linkornone:'mailto' }}{{ object.phone|linkornone:'tel' }}{{ object.notes|yesno|capfirst }}{{ object.union_account|yesno|capfirst }} - -
Nothing found
-
-
-{% if is_paginated %} -
- {% paginator %} -
-{% endif %} diff --git a/templates/partials/search.html b/templates/partials/search.html index 33e9257a..20264c1b 100644 --- a/templates/partials/search.html +++ b/templates/partials/search.html @@ -1,10 +1,10 @@ {% if user.is_authenticated %} -
+
- @@ -17,7 +17,7 @@
- +
{% endif %} diff --git a/users/templates/partials/navbar_user.html b/users/templates/partials/navbar_user.html index a9828fa1..b929b702 100644 --- a/users/templates/partials/navbar_user.html +++ b/users/templates/partials/navbar_user.html @@ -3,7 +3,7 @@ -
-
  • +
  • -
  • - Logout -
  • +
  • Logout
  • {% else %}