Skip to content

Commit

Permalink
Add a view suitable for embedding elsewhere
Browse files Browse the repository at this point in the history
This view lacks the usual navigation features, footers and headers.
  • Loading branch information
andrewshadura committed Aug 9, 2019
1 parent 2e353c9 commit 4c6e982
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
79 changes: 79 additions & 0 deletions wafer/schedule/templates/wafer.schedule/embed_schedule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{% load static from staticfiles %}
{% load i18n %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% trans "Schedule" %} - {{ WAFER_CONFERENCE_NAME }}{% endblock %}</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{% static 'vendor/bootstrap/dist/css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'vendor/@fortawesome/fontawesome-free-webfonts/css/fontawesome.css' %}" rel="stylesheet">
<link href="{% static 'vendor/@fortawesome/fontawesome-free-webfonts/css/fa-solid.css' %}" rel="stylesheet">
<link href="{% static 'css/wafer.css' %}" rel="stylesheet">
{% block extra_head %}{% endblock %}
</head>
<body>
{% block content %}
<section class="wafer wafer-schedule">
<div class="wafer_schedule">
{% if not schedule_days %}
{# Schedule is incomplete / invalid, so show nothing #}
{% blocktrans %}
<p>The final schedule has not been published yet.</p>
{% endblocktrans %}
{% else %}
{% if next_day or prev_day %}
<div class="clearfix d-print-none">
{% url 'wafer_full_schedule' as schedule_url %}
{% if prev_day %}
<a href="{{ schedule_url }}?day={{ prev_day }}"
class="float-left btn btn-secondary btn-lg">{% trans "Previous Day" %}</a>
{% endif %}
{% if next_day %}
<a href="{{ schedule_url }}?day={{ next_day }}"
class="float-right btn btn-secondary btn-lg">{% trans "Next Day" %}</a>
{% endif %}
</div>
{% endif %}
{% for schedule_day in schedule_days %}
<table cellspacing=1 cellpadding=0 class="table table-striped table-bordered">
{# We assume that the admin has created a valid timetable #}
<tr>
<td colspan="{{ schedule_day.venues|length|add:1 }}" class="title">
<a href="?day={{ schedule_day.day.date.isoformat }}">
{{ schedule_day.day.date|date:"l (d b)" }}
</a>
</td>
</tr>
<tr>
<th>{% trans "Time" %}</th>
{% for venue in schedule_day.venues %}
<th><a href="{{ venue.get_absolute_url }}">{{ venue.name }}</a></th>
{% endfor %}
</tr>
{% for row in schedule_day.rows %}
<tr>
<td class="scheduleslot">{{ row.slot.get_start_time|time:"H:i" }} - {{ row.slot.end_time|time:"H:i" }}</td>
{% 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 #}
<td colspan="{{ item.colspan }}" rowspan="{{ item.rowspan }}" class="unavailable"></td>
{% else %}
{# Add item details #}
<td colspan="{{ item.colspan }}" rowspan="{{ item.rowspan }}"
class="{{ item.item.get_css_classes|join:' ' }}">
{% include "wafer.schedule/schedule_item.html" with item=item.item %}
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</table>
{% endfor %}
{% endif %}
</div>
</section>
{% endblock %}
</body>
</html>
3 changes: 2 additions & 1 deletion wafer/schedule/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

from wafer.schedule.views import (
CurrentView, ScheduleView, ScheduleItemViewSet, ScheduleXmlView,
VenueView, ICalView)
ScheduleEmbedView, VenueView, ICalView)

router = routers.DefaultRouter()
router.register(r'scheduleitems', ScheduleItemViewSet)

urlpatterns = [
url(r'^$', ScheduleView.as_view(), name='wafer_full_schedule'),
url(r'^venue/(?P<pk>\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'),
Expand Down
4 changes: 4 additions & 0 deletions wafer/schedule/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 4c6e982

Please sign in to comment.