mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 21:42:14 +00:00
Better approach to generic list templates + other deduplication
This commit is contained in:
@@ -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', "")
|
||||
|
||||
|
||||
22
RIGS/hs.py
22
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{% extends 'base_rigs.html' %}
|
||||
{% load static %}
|
||||
|
||||
|
||||
{% block title %}Calendar{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
@@ -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" %}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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 %}
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
7
RIGS/templates/partials/review_status.html
Normal file
7
RIGS/templates/partials/review_status.html
Normal 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 %}
|
||||
@@ -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 %}
|
||||
@@ -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 %}
|
||||
|
||||
@@ -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 %}
|
||||
@@ -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}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 %}
|
||||
<h1>Asset List</h1>
|
||||
<div class="row justify-content-end">
|
||||
<form id="asset-search-form" method="GET" class="form-inline">
|
||||
<div class="input-group px-1">
|
||||
{% render_field form.q|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' %}
|
||||
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||
<span class="input-group-append"><button type="submit" class="btn btn-info" id="id_search" style="width: 6em">Search</button></span>
|
||||
</div>
|
||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="category" class="sr-only">Category</label>
|
||||
{% 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" %}
|
||||
</div>
|
||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="status" class="sr-only">Status</label>
|
||||
{% 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" %}
|
||||
</div>
|
||||
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||
</form>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<form id="asset-search-form" method="GET" class="form-inline justify-content-end">
|
||||
<div class="input-group px-1 mb-2 mb-sm-0 flex-nowrap">
|
||||
{% render_field form.q|add_class:'form-control' placeholder='Enter Asset ID/Desc/Serial' %}
|
||||
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||
<span class="input-group-append">{% button 'search' id="id_search" style="width: 6em" %}</span>
|
||||
</div>
|
||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="category" class="sr-only">Category</label>
|
||||
{% 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" %}
|
||||
</div>
|
||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="status" class="sr-only">Status</label>
|
||||
{% 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" %}
|
||||
</div>
|
||||
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-end">
|
||||
<a href="{% url 'asset_create' %}" class="btn btn-primary my-2" style="width: 6em">New <span class="fas fa-plus"></span></a>
|
||||
<div class="row my-2">
|
||||
<div class="col text-right">
|
||||
{% button 'new' 'asset_create' style="width: 6em" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{% include 'partials/asset_list_table.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% if is_paginated %}
|
||||
<div class="text-center">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% paginator %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block titleheader %}
|
||||
<a class="nav navbar-brand navbar-left" href="/"><span class="fas fa-arrow-circle-left align-middle"></span> RIGS</a>
|
||||
<a class="nav navbar-brand" href="{% url 'asset_index' %}">Assets</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block titleelements %}
|
||||
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Assets</a>
|
||||
<div class="dropdown-menu">
|
||||
@@ -19,7 +19,7 @@
|
||||
{% endif %}
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{% url 'cable_type_list' %}"><span class="fas fa-list"></span> List Cable Types</a>
|
||||
{% if perms.assets.add_cable_type %}
|
||||
{% if perms.assets.add_cabletype %}
|
||||
<a class="dropdown-item" href="{% url 'cable_type_create' %}"><span class="fas fa-plus"></span> Create Cable Type</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% load button from filters %}
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead class="thead-dark">
|
||||
@@ -21,10 +22,10 @@
|
||||
<a type="button" class="btn btn-info btn-sm modal-href" href="{% url 'asset_audit' item.asset_id %}"><i class="fas fa-certificate"></i> Audit</a>
|
||||
{% else %}
|
||||
<div class="btn-group" role="group">
|
||||
<a type="button" class="btn btn-primary btn-sm" href="{% url 'asset_detail' item.asset_id %}"><i class="fas fa-eye"></i><span class="d-none d-sm-inline"> View</span></a>
|
||||
{% button 'view' url='asset_detail' pk=item.asset_id clazz="btn-sm" %}
|
||||
{% if perms.assets.change_asset %}
|
||||
<a type="button" class="btn btn-warning btn-sm" href="{% url 'asset_update' item.asset_id %}"><i class="fas fa-edit"></i><span class="d-none d-sm-inline"> Edit</span></a>
|
||||
<a type="button" class="btn btn-info btn-sm" href="{% url 'asset_duplicate' item.asset_id %}"><i class="fas fa-clone"></i><span class="d-none d-sm-inline"> Duplicate</span></a>
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% block title %}Supplier List{% endblock %}
|
||||
{% load paginator from filters %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<h3>Suppliers</h3>
|
||||
</div>
|
||||
{% include 'partials/generic_list.html' with edit="supplier_update" detail="supplier_detail" create="supplier_create" %}
|
||||
{% endblock %}
|
||||
@@ -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
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
|
||||
lang="{% firstof LANGUAGE_CODE 'en' %}">
|
||||
<head>
|
||||
<title>{% block title %}{% endblock %} | Rig Information Gathering System</title>
|
||||
<title>{{page_title}}{% block title %}{% endblock %} | Rig Information Gathering System</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@@ -70,7 +70,7 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% if page_title %}<h2>{{page_title}}</h2>{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{% if submit %}
|
||||
<button type="submit" class="btn {{ class }}" title="{{ text }}"><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></button>
|
||||
{% elif id %}
|
||||
<a href="{% url target id %}" class="btn {{ class }}"><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
|
||||
{% else %}
|
||||
<a href="{% url target %}" class="btn {{ class }}"><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
|
||||
{% endif %}
|
||||
70
templates/generic_list.html
Normal file
70
templates/generic_list.html
Normal file
@@ -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 %}
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
<form class="form-inline">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
<input type="search" name="q" placeholder="Search" value="{{ request.GET.q }}"
|
||||
class="form-control"/>
|
||||
<span class="input-group-append">{% button 'search' id="id_search" %}</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row py-3">
|
||||
<div class="col text-right">
|
||||
{% button 'new' url=create %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<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 id="row_item">
|
||||
<th scope="row" class="align-middle" id="cell_name">{{ object.name }}</th>
|
||||
<td class="align-middle">{{ object.email|linkornone:'mailto' }}</td>
|
||||
<td class="align-middle">{{ object.phone|linkornone:'tel' }}</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">
|
||||
{% button 'view' url=detail pk=object.pk clazz="btn-sm modal-href" %}
|
||||
{% button 'edit' url=edit pk=object.pk clazz="btn-sm modal-href" %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr class="table-warning">
|
||||
<td colspan="6" class="text-center">Nothing found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% paginator %}
|
||||
{% endblock%}
|
||||
@@ -31,7 +31,7 @@
|
||||
<h4 class="card-header">Quick Links</h4>
|
||||
<div class="list-group list-group-flush">
|
||||
<a class="list-group-item list-group-item-action" href="https://forum.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><i class="fas fa-comment-alt"></i> TEC Forum</a>
|
||||
<a class="list-group-item list-group-item-action" href="//members.nottinghamtec.co.uk/wiki" target="_blank" rel="noopener noreferrer"><i class="fas fa-pen-square"></i> TEC Wiki</a>
|
||||
<a class="list-group-item list-group-item-action" href="//wiki.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><i class="fas fa-pen-square"></i> TEC Wiki</a>
|
||||
{% if perms.RIGS.view_event %}
|
||||
<a class="list-group-item list-group-item-action" href="//members.nottinghamtec.co.uk/price" target="_blank"><i class="fas fa-pound-sign"></i> Price List</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
{% load url_replace from filters %}
|
||||
{% if is_paginated %}
|
||||
{% load url_replace from filters %}
|
||||
<div class="row justify-content-center pt-3">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
{% if has_previous %}
|
||||
<li class="page-item"><a class="page-link" href="?{% url_replace request 'page' previous %}">‹‹</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<ul class="pagination">
|
||||
{% if has_previous %}
|
||||
<li class="page-item"><a class="page-link" href="?{% url_replace request 'page' previous %}">‹‹</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link" aria-hidden="true">‹‹</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if show_first %}
|
||||
<li class="page-item"><a class="page-link" href="?{% url_replace request 'page' first %}" class="prev">{{ first }}</a></li>
|
||||
@@ -37,4 +38,5 @@
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
7
templates/partials/button.html
Normal file
7
templates/partials/button.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{% if submit %}
|
||||
<button type="submit" class="btn {{ class }}" title="{{ text }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></button>
|
||||
{% elif pk %}
|
||||
<a href="{% url target pk %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
|
||||
{% else %}
|
||||
<a href="{% url target %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
|
||||
{% endif %}
|
||||
@@ -1,67 +0,0 @@
|
||||
{% load url_replace from filters %}
|
||||
{% load orderby from filters %}
|
||||
{% load paginator from filters %}
|
||||
{% load linkornone from filters %}
|
||||
<div class="row justify-content-end">
|
||||
<form class="form-inline">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
<input type="search" name="q" placeholder="Search" value="{{ request.GET.q }}"
|
||||
class="form-control"/>
|
||||
<span class="input-group-append"><button type="submit" class="btn btn-info" id="id_search">Search</button></span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row justify-content-end py-3">
|
||||
<a href="{% url create %}" class="btn btn-primary">New <span
|
||||
class="fas fa-plus"></span></a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<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 id="row_item">
|
||||
<th scope="row" class="align-middle" id="cell_name">{{ object.name }}</th>
|
||||
<td class="align-middle">{{ object.email|linkornone:'mailto' }}</td>
|
||||
<td class="align-middle">{{ object.phone|linkornone:'tel' }}</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>
|
||||
</div>
|
||||
</div>
|
||||
{% if is_paginated %}
|
||||
<div class="row justify-content-center">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -1,10 +1,10 @@
|
||||
{% if user.is_authenticated %}
|
||||
<form id="searchForm" class="form-inline flex-nowrap mx-md-3" role="form" method="GET" action="{% url 'event_archive' %}">
|
||||
<form id="searchForm" class="form-inline flex-nowrap mx-md-3 px-2 border border-light rounded" role="form" method="GET" action="{% url 'event_archive' %}">
|
||||
<div class="input-group input-group-sm flex-nowrap">
|
||||
<div class="input-group-prepend">
|
||||
<input id="id_search_input" type="search" name="q" class="form-control form-control-sm" placeholder="Search..." value="{{ request.GET.q }}" />
|
||||
</div>
|
||||
<select id="search-options" class="custom-select form-control w-25" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px;">
|
||||
<select id="search-options" class="custom-select form-control" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px; width: 20ch;">
|
||||
<option selected data-action="{% url 'event_archive' %}" href="#">Events</option>
|
||||
<option data-action="{% url 'person_list' %}" href="#">People</option>
|
||||
<option data-action="{% url 'organisation_list' %}" href="#">Organisations</option>
|
||||
@@ -17,7 +17,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-info form-control form-control-sm btn-sm w-25" style="border-top-left-radius: 0px;border-bottom-left-radius: 0px;"><span class="fas fa-search"></span><span class="sr-only"> Search</span></button>
|
||||
<a href="{% url 'search_help' %}" class="nav-link modal-href btn-sm ml-2"><span class="fas fa-question-circle"></span></a>
|
||||
<a href="{% url 'search_help' %}" class="nav-link modal-href ml-2"><span class="fas fa-question-circle"></span></a>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Hi {{ user.first_name }}
|
||||
</a>
|
||||
<ul class="dropdown-menu p-3" id="userdropdown">
|
||||
<ul class="dropdown-menu p-3 clearfix" id="userdropdown">
|
||||
<li class="media">
|
||||
<a href="{% url 'profile_detail' %}">
|
||||
<img src="{{ request.user.profile_picture }}" class="media-object"/>
|
||||
@@ -13,15 +13,13 @@
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li class="mb-2">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="darkSwitch" />
|
||||
<label class="custom-control-label" for="darkSwitch">Dark Mode</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'logout' %}" class="btn btn-primary align"><i class="fas fa-sign-out-alt"></i> Logout</a>
|
||||
</li>
|
||||
<li class="float-right"><a href="{% url 'logout' %}" class="btn btn-primary"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<a class="nav-link" href="{% url 'login' %}">
|
||||
|
||||
Reference in New Issue
Block a user