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 %} -