Rework of subhire list

This commit is contained in:
2022-12-19 17:33:01 +00:00
parent 773f55ac84
commit 1615e27767
10 changed files with 182 additions and 59 deletions

View File

@@ -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