From 3348d96d063734796134f28d8c9168519f816508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Mon, 24 Jun 2019 15:11:24 +0200 Subject: [PATCH] Add show_schedule boolean to Camp. Hide schedule link if schedule should not be shown. Close #346 --- src/camps/models.py | 4 ++++ src/program/templates/includes/program_menu.html | 2 ++ src/program/views.py | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/camps/models.py b/src/camps/models.py index b0028495..3e15d424 100644 --- a/src/camps/models.py +++ b/src/camps/models.py @@ -104,6 +104,10 @@ class Camp(CreatedUpdatedModel, UUIDModel): default="The Call For Sponsors for this Camp has not been written yet", ) + show_schedule = models.BooleanField( + help_text="Check if the schedule should be shown.", default=True + ) + def get_absolute_url(self): return reverse("camp_detail", kwargs={"camp_slug": self.slug}) diff --git a/src/program/templates/includes/program_menu.html b/src/program/templates/includes/program_menu.html index d5439a8b..f637415c 100644 --- a/src/program/templates/includes/program_menu.html +++ b/src/program/templates/includes/program_menu.html @@ -1,4 +1,6 @@ +{% if camp.show_schedule %} Schedule +{% endif %} Events Speakers Call for Participation diff --git a/src/program/views.py b/src/program/views.py index ef11ef9a..e0bdacc8 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -801,12 +801,16 @@ class ScheduleView(CampViewMixin, TemplateView): If no events are scheduled redirect to the event page """ response = super().dispatch(request, *args, **kwargs) - if not models.EventInstance.objects.filter( + + events_exist = models.EventInstance.objects.filter( event__track__camp=self.camp - ).exists(): + ).exists() + + if not self.camp.show_schedule or not events_exist: return redirect( reverse("program:event_index", kwargs={"camp_slug": self.camp.slug}) ) + return response def get_context_data(self, *args, **kwargs):