From 11a94b477c37c81a7a1afc1cfec39627ff4609f2 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Wed, 18 Jul 2018 00:58:33 +0200 Subject: [PATCH] redirect to the events list if nothing is scheduled yet --- src/program/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/program/views.py b/src/program/views.py index c9995b4a..bc9bf221 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -672,6 +672,15 @@ class NoScriptScheduleView(CampViewMixin, TemplateView): class ScheduleView(CampViewMixin, TemplateView): template_name = 'schedule_overview.html' + def dispatch(self, request, *args, **kwargs): + """ + If no events are scheduled redirect to the event page + """ + response = super().dispatch(request, *args, **kwargs) + if not models.EventInstance.objects.filter(event__track__camp=self.camp).exists(): + return(redirect(reverse('program:event_index', kwargs={'camp_slug': self.camp.slug}))) + return response + def get_context_data(self, *args, **kwargs): context = super(ScheduleView, self).get_context_data(**kwargs) context['schedule_midnight_offset_hours'] = settings.SCHEDULE_MIDNIGHT_OFFSET_HOURS