mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-27 18:32:16 +00:00
Rework of subhire list
This commit is contained in:
@@ -204,27 +204,7 @@ class EventArchive(generic.ListView):
|
||||
"Muppet! Check the dates, it has been fixed for you.")
|
||||
start, end = end, start # Stop the impending fail
|
||||
|
||||
filter = Q()
|
||||
if end != "":
|
||||
filter &= Q(start_date__lte=end)
|
||||
if start:
|
||||
filter &= Q(start_date__gte=start)
|
||||
|
||||
q = self.request.GET.get('q', "")
|
||||
objects = self.model.objects.all()
|
||||
|
||||
if q:
|
||||
objects = self.model.objects.search(q)
|
||||
|
||||
status = self.request.GET.getlist('status', "")
|
||||
|
||||
if len(status) > 0:
|
||||
filter &= Q(status__in=status)
|
||||
|
||||
qs = objects.filter(filter).order_by('-start_date')
|
||||
|
||||
# Preselect related for efficiency
|
||||
qs.select_related('person', 'organisation', 'venue', 'mic')
|
||||
qs = self.model.objects.event_search(self.request.GET.get('q', None), start, end, self.request.GET.get('status', ""))
|
||||
|
||||
if not qs.exists():
|
||||
messages.add_message(self.request, messages.WARNING, "No events have been found matching those criteria.")
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from django.urls import reverse_lazy
|
||||
from django.views import generic
|
||||
from django.db.models import Sum
|
||||
from PyRIGS.views import ModalURLMixin, get_related
|
||||
from RIGS import models, forms
|
||||
from RIGS.views import EventArchive
|
||||
|
||||
|
||||
class SubhireDetail(generic.DetailView, ModalURLMixin):
|
||||
@@ -48,11 +50,13 @@ class SubhireEdit(generic.UpdateView):
|
||||
return reverse_lazy('subhire_detail', kwargs={'pk': self.object.pk})
|
||||
|
||||
|
||||
class SubhireList(generic.TemplateView):
|
||||
template_name = 'rigboard.html'
|
||||
class SubhireList(EventArchive):
|
||||
template_name = 'subhire_list.html'
|
||||
model = models.Subhire
|
||||
paginate_by = 25
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['events'] = models.Subhire.objects.current_events()
|
||||
context['page_title'] = "Upcoming Subhire"
|
||||
context['total_value'] = self.get_queryset().aggregate(sum=Sum('insurance_value'))['sum']
|
||||
context['page_title'] = "Subhire List"
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user