From 3411aee34a2fe5212fe3d07b2972891e7fe0df8a Mon Sep 17 00:00:00 2001 From: Vidir Valberg Gudmundsson Date: Sun, 23 Jul 2017 11:31:22 +0200 Subject: [PATCH] Make a noscript fallback version of the schedule. --- src/bornhack/urls.py | 5 ++ src/program/templates/schedule_overview.html | 19 +++++++ src/program/views.py | 52 ++++---------------- 3 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/bornhack/urls.py b/src/bornhack/urls.py index e2092980..aa3eec00 100644 --- a/src/bornhack/urls.py +++ b/src/bornhack/urls.py @@ -132,6 +132,11 @@ urlpatterns = [ ScheduleView.as_view(), name='schedule_index' ), + url( + r'^noscript/$', + NoScriptScheduleView.as_view(), + name='noscript_schedule_index' + ), url( r'^ics/', ICSView.as_view(), name="ics_view" ), diff --git a/src/program/templates/schedule_overview.html b/src/program/templates/schedule_overview.html index b6776e33..f12afe7c 100644 --- a/src/program/templates/schedule_overview.html +++ b/src/program/templates/schedule_overview.html @@ -3,8 +3,27 @@ {% load commonmark %} {% load staticfiles %} +{% block extra_head %} + +{% endblock %} + {% block program_content %} + +
diff --git a/src/program/views.py b/src/program/views.py index ca63e4b5..dc16c036 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -263,54 +263,22 @@ class EventDetailView(CampViewMixin, DetailView): ################## schedule ############################################# +class NoScriptScheduleView(CampViewMixin, TemplateView): + template_name = "noscript_schedule_view.html" + + def get_context_data(self, *args, **kwargs): + context = super().get_context_data(**kwargs) + context['eventinstances'] = models.EventInstance.objects.filter(event__camp=self.camp).order_by('when') + return context + + + class ScheduleView(CampViewMixin, TemplateView): template_name = 'schedule_overview.html' def get_context_data(self, *args, **kwargs): context = super(ScheduleView, self).get_context_data(**kwargs) - - # Do stuff if we are dealing with a day schedule - if 'day' in kwargs: - when = datetime.datetime(year=int(self.kwargs['year']), month=int(self.kwargs['month']), day=int(self.kwargs['day'])) - eventinstances = models.EventInstance.objects.filter(event__in=self.camp.events.all()) - skip = [] - for ei in eventinstances: - if ei.schedule_date != when.date(): - skip.append(ei.id) - else: - if 'type' in self.request.GET: - eventtype = models.EventType.objects.get( - slug=self.request.GET['type'] - ) - if ei.event.event_type != eventtype: - skip.append(ei.id) - eventinstances = eventinstances.exclude(id__in=skip).order_by('event__event_type') - if 'location' in self.request.GET: - eventlocation = models.EventLocation.objects.get( - camp=self.camp, - slug=self.request.GET['location'] - ) - eventinstances = eventinstances.filter(location=eventlocation) - - context['eventinstances'] = eventinstances - - start = when + datetime.timedelta(hours=settings.SCHEDULE_MIDNIGHT_OFFSET_HOURS) - timeslots = [] - # calculate how many timeslots we have in the schedule based on the lenght of the timeslots in minutes, - # and the number of minutes in 24 hours - for i in range(0,int((24*60)/settings.SCHEDULE_TIMESLOT_LENGTH_MINUTES)): - timeslot = start + datetime.timedelta(minutes=i*settings.SCHEDULE_TIMESLOT_LENGTH_MINUTES) - timeslots.append(timeslot) - context['timeslots'] = timeslots - - # include the components to make the urls - context['urlyear'] = self.kwargs['year'] - context['urlmonth'] = self.kwargs['month'] - context['urlday'] = self.kwargs['day'] - - context['schedule_timeslot_length_minutes'] = settings.SCHEDULE_TIMESLOT_LENGTH_MINUTES; context['schedule_midnight_offset_hours'] = settings.SCHEDULE_MIDNIGHT_OFFSET_HOURS; - return context