Add show_schedule boolean to Camp. Hide schedule link if schedule should not be shown. Close #346

This commit is contained in:
Víðir Valberg Guðmundsson 2019-06-24 15:11:24 +02:00
parent 04b8c37f76
commit 3348d96d06
3 changed files with 12 additions and 2 deletions

View File

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

View File

@ -1,4 +1,6 @@
{% if camp.show_schedule %}
<a href="{% url 'program:schedule_index' camp_slug=camp.slug %}" class="btn {% if url_name == "schedule_index" or urlyear %}btn-primary{% else %}btn-default{% endif %}">Schedule</a>
{% endif %}
<a href="{% url 'program:event_index' camp_slug=camp.slug %}" class="btn {% if url_name == "event_index" %}btn-primary{% else %}btn-default{% endif %}">Events</a>
<a href="{% url 'program:speaker_index' camp_slug=camp.slug %}" class="btn {% if url_name == "speaker_index" %}btn-primary{% else %}btn-default{% endif %}">Speakers</a>
<a href="{% url 'program:call_for_participation' camp_slug=camp.slug %}" class="btn {% if url_name == "call_for_participation" %}btn-primary{% else %}btn-default{% endif %}">Call for Participation</a>

View File

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