From 0ac9d49e63857ed88f6e451cb961540a5393c6dc Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Fri, 9 Aug 2019 19:34:52 +0200 Subject: [PATCH] Add a view suitable for embedding elsewhere This view lacks the usual navigation features, footers and headers. --- .../wafer.schedule/embed_schedule.html | 25 ++++++++ .../wafer.schedule/full_schedule.html | 60 +------------------ .../wafer.schedule/static_schedule.html | 58 ++++++++++++++++++ wafer/schedule/urls.py | 3 +- wafer/schedule/views.py | 4 ++ 5 files changed, 92 insertions(+), 58 deletions(-) create mode 100644 wafer/schedule/templates/wafer.schedule/embed_schedule.html create mode 100644 wafer/schedule/templates/wafer.schedule/static_schedule.html diff --git a/wafer/schedule/templates/wafer.schedule/embed_schedule.html b/wafer/schedule/templates/wafer.schedule/embed_schedule.html new file mode 100644 index 00000000..bd1ddfc4 --- /dev/null +++ b/wafer/schedule/templates/wafer.schedule/embed_schedule.html @@ -0,0 +1,25 @@ +{% load static from staticfiles %} +{% load i18n %} + + + + {% block title %}{% trans "Schedule" %} - {{ WAFER_CONFERENCE_NAME }}{% endblock %} + + + + + + + + {% block extra_head %}{% endblock %} + + +{% block content %} +
+ {% block schedule_grid %} + {% include "wafer.schedule/static_schedule.html" %} + {% endblock %} +
+{% endblock %} + + diff --git a/wafer/schedule/templates/wafer.schedule/full_schedule.html b/wafer/schedule/templates/wafer.schedule/full_schedule.html index e1498e45..a9bf3253 100644 --- a/wafer/schedule/templates/wafer.schedule/full_schedule.html +++ b/wafer/schedule/templates/wafer.schedule/full_schedule.html @@ -14,62 +14,8 @@

{% trans "Schedule" %}

-
- {% if not schedule_days %} - {# Schedule is incomplete / invalid, so show nothing #} - {% blocktrans %} -

The final schedule has not been published yet.

- {% endblocktrans %} - {% else %} - {% if next_day or prev_day %} -
- {% url 'wafer_full_schedule' as schedule_url %} - {% if prev_day %} - {% trans "Previous Day" %} - {% endif %} - {% if next_day %} - {% trans "Next Day" %} - {% endif %} -
- {% endif %} - {% for schedule_day in schedule_days %} - - {# We assume that the admin has created a valid timetable #} - - - - - - {% for venue in schedule_day.venues %} - - {% endfor %} - - {% for row in schedule_day.rows %} - - - {% for item in row.get_sorted_items %} - {% if item.item == "unavailable" %} - {# Venue isn't available, so we add an empty table element with the 'unavailable' class #} - - {% else %} - {# Add item details #} - - {% endif %} - {% endfor %} - - {% endfor %} -
- - {{ schedule_day.day.date|date:"l (d b)" }} - -
{% trans "Time" %}{{ venue.name }}
{{ row.slot.get_start_time|time:"H:i" }} - {{ row.slot.end_time|time:"H:i" }} - {% include "wafer.schedule/schedule_item.html" with item=item.item %} -
- {% endfor %} - {% endif %} -
+ {% block schedule_grid %} + {% include "wafer.schedule/static_schedule.html" %} + {% endblock %} {% endblock %} diff --git a/wafer/schedule/templates/wafer.schedule/static_schedule.html b/wafer/schedule/templates/wafer.schedule/static_schedule.html new file mode 100644 index 00000000..098a8359 --- /dev/null +++ b/wafer/schedule/templates/wafer.schedule/static_schedule.html @@ -0,0 +1,58 @@ + {% load i18n %} +
+ {% if not schedule_days %} + {# Schedule is incomplete / invalid, so show nothing #} + {% blocktrans %} +

The final schedule has not been published yet.

+ {% endblocktrans %} + {% else %} + {% if next_day or prev_day %} +
+ {% url 'wafer_full_schedule' as schedule_url %} + {% if prev_day %} + {% trans "Previous Day" %} + {% endif %} + {% if next_day %} + {% trans "Next Day" %} + {% endif %} +
+ {% endif %} + {% for schedule_day in schedule_days %} + + {# We assume that the admin has created a valid timetable #} + + + + + + {% for venue in schedule_day.venues %} + + {% endfor %} + + {% for row in schedule_day.rows %} + + + {% for item in row.get_sorted_items %} + {% if item.item == "unavailable" %} + {# Venue isn't available, so we add an empty table element with the 'unavailable' class #} + + {% else %} + {# Add item details #} + + {% endif %} + {% endfor %} + + {% endfor %} +
+ + {{ schedule_day.day.date|date:"l (d b)" }} + +
{% trans "Time" %}{{ venue.name }}
{{ row.slot.get_start_time|time:"H:i" }} - {{ row.slot.end_time|time:"H:i" }} + {% include "wafer.schedule/schedule_item.html" with item=item.item %} +
+ {% endfor %} + {% endif %} +
diff --git a/wafer/schedule/urls.py b/wafer/schedule/urls.py index 4887c3ee..c327fdb5 100644 --- a/wafer/schedule/urls.py +++ b/wafer/schedule/urls.py @@ -4,7 +4,7 @@ from wafer.schedule.views import ( CurrentView, ScheduleView, ScheduleItemViewSet, ScheduleXmlView, - VenueView, ICalView) + ScheduleEmbedView, VenueView, ICalView) router = routers.DefaultRouter() router.register(r'scheduleitems', ScheduleItemViewSet) @@ -12,6 +12,7 @@ urlpatterns = [ url(r'^$', ScheduleView.as_view(), name='wafer_full_schedule'), url(r'^venue/(?P\d+)/$', VenueView.as_view(), name='wafer_venue'), + url(r'^embed/$', ScheduleEmbedView.as_view(), name='wafer_current'), url(r'^current/$', CurrentView.as_view(), name='wafer_current'), url(r'^pentabarf\.xml$', ScheduleXmlView.as_view(), name='wafer_pentabarf_xml'), diff --git a/wafer/schedule/views.py b/wafer/schedule/views.py index 37f97914..04430d0e 100644 --- a/wafer/schedule/views.py +++ b/wafer/schedule/views.py @@ -171,6 +171,10 @@ def get_context_data(self, **kwargs): return context +class ScheduleEmbedView(ScheduleView): + template_name = 'wafer.schedule/embed_schedule.html' + + class CurrentView(TemplateView): template_name = 'wafer.schedule/current.html'