Add show_schedule boolean to Camp. Hide schedule link if schedule should not be shown. Close #346
This commit is contained in:
parent
04b8c37f76
commit
3348d96d06
|
@ -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})
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue