diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/templates/v2/current_show.html | 56 | ||||
-rw-r--r-- | program/templates/v2/day_schedule.html | 101 | ||||
-rw-r--r-- | program/templates/v2/filters/broadcastformat.html | 6 | ||||
-rw-r--r-- | program/templates/v2/filters/language.html | 6 | ||||
-rw-r--r-- | program/templates/v2/filters/musicfocus.html | 6 | ||||
-rw-r--r-- | program/templates/v2/filters/showinformation.html | 6 | ||||
-rw-r--r-- | program/templates/v2/filters/showtopic.html | 6 | ||||
-rw-r--r-- | program/templates/v2/host_detail.html | 27 | ||||
-rw-r--r-- | program/templates/v2/host_list.html | 19 | ||||
-rw-r--r-- | program/templates/v2/recommendation.html | 28 | ||||
-rw-r--r-- | program/templates/v2/recommendation_list.html | 47 | ||||
-rw-r--r-- | program/templates/v2/show_detail.html | 88 | ||||
-rw-r--r-- | program/templates/v2/show_list.html | 57 | ||||
-rw-r--r-- | program/templates/v2/timeslot_detail.html | 57 | ||||
-rw-r--r-- | program/templatetags/filters.py | 30 | ||||
-rw-r--r-- | program/urls.py | 13 | ||||
-rw-r--r-- | program/views.py | 130 |
17 files changed, 682 insertions, 1 deletions
diff --git a/program/templates/v2/current_show.html b/program/templates/v2/current_show.html new file mode 100644 index 0000000..3ffe8c4 --- /dev/null +++ b/program/templates/v2/current_show.html @@ -0,0 +1,56 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"/> + <title>Current program box</title> +</head> +<body> + <ul> +{% if previous_timeslot %} + <li id="previous" class="bf-{{ previous_timeslot.show.broadcastformat.slug }}"> + <div class="time">{{ previous_timeslot.start|date:"H:i" }}</div> + <div class="show-name"> + <a href="{% url "timeslot-detail" previous_timeslot.id %}">{{ previous_timeslot.show.name }}</a> + </div> + <div class="show-content"> + </div> + </li> +{% endif %} +{% if current_timeslot %} + <li id="current" class="bf-{{ current_timeslot.show.broadcastformat.slug }}"> + <div class="time">{{ current_timeslot.start|date:"H:i" }}</div> + <div class="show-name"> + <a href="{% url "timeslot-detail" current_timeslot.id %}">{{ current_timeslot.show.name }}</a> + </div> + <div class="show-content"> +{% if current_timeslot.note %} + {{ current_timeslot.note.title }} +{% else %} + {{ current_timeslot.show.short_description }} +{% endif %} + </div> + </li> +{% endif %} +{% if next_timeslot %} + <li id="next" class="bf-{{ next_timeslot.show.broadcastformat.slug }}"> + <div class="time">{{ next_timeslot.start|date:"H:i" }}</div> + <div class="show-name"> + <a href="{% url "timeslot-detail" next_timeslot.id %}">{{ next_timeslot.show.name }}</a> + </div> + <div class="show-content"> + </div> + </li> +{% endif %} +{% if after_next_timeslot %} + <li id="after_next" class="bf-{{ after_next_timeslot.show.broadcastformat.slug }}"> + <div class="timer">{{ after_next_timeslot.start|date:"H:i" }}</div> + <div class="show-name"> + <a href="{% url "timeslot-detail" after_next_timeslot.id %}">{{ after_next_timeslot.show.name }}</a> + </div> + <div class="show-content"> + </div> + </li> +{% endif %} + </ul> +</body> +</html> diff --git a/program/templates/v2/day_schedule.html b/program/templates/v2/day_schedule.html new file mode 100644 index 0000000..ceb0bee --- /dev/null +++ b/program/templates/v2/day_schedule.html @@ -0,0 +1,101 @@ +<html> +<head> + <title>Tagesansicht {{ day|date:"l, d.m.Y" }} — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +{% load filters %} +<div id="filter-format"> + {% broadcastformatV2 %} +</div> + +<div id="filter-topic"> + <dl id="filter-header" class="portlet"> + <dt class="portletHeader"><span>Filter</span></dt> + </dl> +{% musicfocusV2 %} +{% showinformationV2 %} +{% showtopicV2 %} +{% languageV2 %} +</div> + +<div id="content-main" class="day-schedule"> + <h2>Tagesansicht</h2> + <h1 id="date">{{ day|date:"l, d.m.Y" }}</h1> + + <div id="timeslots"> + {% for timeslot in timeslots %} + {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} + <div class="timeslot bf-{{ default_show.broadcastformat.slug }}"> + <div class="show-start">{{ timeslot.get_previous_by_start.end|date:"H:i" }}</div> + <div class="show-abbrevs"> + {% for si in default_show.showinformation.all %} + <span title="{{ si.information }}" + class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in default_show.showtopic.all %} + <span title="{{ st.topic }}" class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in default_show.musicfocus.all %} + <span title="{{ mf.focus }}" class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + <div class="show-detail"> + <h3 class="show-title">{{ default_show.name }}</h3> + <p class="show-description">{{ default_show.short_description }}</p> + </div> + </div> + {% endif %} + <div class="timeslot bf-{{ timeslot.show.broadcastformat.slug }}"> + <div class="show-start">{{ timeslot.start|date:"H:i" }}</div> + <div class="show-abbrevs"> + {% for si in timeslot.show.showinformation.all %} + <span title="{{ si.information }}" + class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in timeslot.show.showtopic.all %} + <span title="{{ st.topic }}" + class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in timeslot.show.musicfocus.all %} + <span title="{{ mf.focus }}" + class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + <div class="show-detail"> + <h3 class="show-title"><a + href="{% url "timeslot-detail" timeslot.id %}">{{ timeslot.show.name }}</a></h3> + {% if timeslot.note %} + <p class="note-title"><strong>Heute:</strong> {{ timeslot.note.title }}</p> + {% else %} + <p class="show-description">{{ timeslot.show.short_description }}</p> + {% endif %} + </div> + </div> + {% if timeslot.end != timeslot.get_next_by_start.start %} + <div class="timeslot bf-{{ default_show.broadcastformat.slug }}"> + <div class="show-start">{{ timeslot.end|date:"H:i" }}</div> + <div class="show-abbrevs"> + {% for si in default_show.showinformation.all %} + <span title="{{ si.information }}" + class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in default_show.showtopic.all %} + <span title="{{ st.topic }}" class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in default_show.musicfocus.all %} + <span title="{{ mf.focus }}" class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + <div class="show-detail"> + <h3 class="show-title">{{ default_show.name }}</h3> + <p class="show-description">{{ default_show.short_description }}</p> + </div> + </div> + {% endif %} + {% endfor %} + </div> +</div> + +</body> +</html> diff --git a/program/templates/v2/filters/broadcastformat.html b/program/templates/v2/filters/broadcastformat.html new file mode 100644 index 0000000..922c99c --- /dev/null +++ b/program/templates/v2/filters/broadcastformat.html @@ -0,0 +1,6 @@ +{% if broadcastformat_list %} + <ul id="filter_broadcastformat"> +{% for bf in broadcastformat_list %} + <li><a title="Sendungen mit dem Sendungsformat {{ bf.format }} anzeigen." href="?broadcastformat={{ bf.slug }}">{{ bf.format }}</a></li>{% endfor %} + </ul> +{% endif %} diff --git a/program/templates/v2/filters/language.html b/program/templates/v2/filters/language.html new file mode 100644 index 0000000..c79122f --- /dev/null +++ b/program/templates/v2/filters/language.html @@ -0,0 +1,6 @@ +{% if language_list %} + <ul id="filter_language"> +{% for language in language_list %} + <li><a title="Sendungen auf {{ language.name }} anzeigen." href="?language={{ language.slug }}">{{ language.name }}/{{ language.native_name }}</a></li>{% endfor %} + </ul> +{% endif %} diff --git a/program/templates/v2/filters/musicfocus.html b/program/templates/v2/filters/musicfocus.html new file mode 100644 index 0000000..99bbb20 --- /dev/null +++ b/program/templates/v2/filters/musicfocus.html @@ -0,0 +1,6 @@ +{% if musicfocus_list %} + <ul id="filter_musicfocus"> +{% for mf in musicfocus_list %} + <li><a title="Sendungen mit der Musiktendenz {{ mf.focus }} anzeigen." class="abbrev mf-{{ mf.abbrev }}" href="?musicfocus={{ mf.slug }}">{{ mf.focus }}</a></li>{% endfor %} + </ul> +{% endif %} diff --git a/program/templates/v2/filters/showinformation.html b/program/templates/v2/filters/showinformation.html new file mode 100644 index 0000000..bcd6cb1 --- /dev/null +++ b/program/templates/v2/filters/showinformation.html @@ -0,0 +1,6 @@ +{% if showinformation_list %} + <ul id="filter_showinformation"> +{% for si in showinformation_list %} + <li><a title="Sendungen mit der Information {{ si.information }} anzeigen." href="?showinformation={{ si.slug }}">{{ si.information }}</a></li>{% endfor %} + </ul> +{% endif %} diff --git a/program/templates/v2/filters/showtopic.html b/program/templates/v2/filters/showtopic.html new file mode 100644 index 0000000..070d82a --- /dev/null +++ b/program/templates/v2/filters/showtopic.html @@ -0,0 +1,6 @@ +{% if showtopic_list %} + <ul id="filter_showtopic"> +{% for showtopic in showtopic_list %} + <li><a title="Sendungen mit dem Schwerpunkt {{ showtopic.topic }} anzeigen." href="?showtopic={{ showtopic.slug }}">{{ showtopic.topic }}</a></li>{% endfor %} + </ul> +{% endif %} diff --git a/program/templates/v2/host_detail.html b/program/templates/v2/host_detail.html new file mode 100644 index 0000000..e7aad16 --- /dev/null +++ b/program/templates/v2/host_detail.html @@ -0,0 +1,27 @@ +<html> +<head> + <title>Host: {{ host.name }} — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +<div id="content-main" class="host-detail"> + <div id="name">{{ host.name }}</div> + + <div id="shows"> + <div id="shows-title">Sendungen</div> + {% for show in host.active_shows %} + <div class="show {{ show.broadcastformat.slug }}"><a href="{% url "show-detail" show.slug %}"> {{ show.name }}</a></div> + {% endfor %} + </div> + + {% if host.email %} + <div id="email">E-Mail Adresse: <a href="{{ host.email }}">{{ host.email }}</a></div> + {% endif %} + + {% if host.website %} + <div id="website">Website: <a href="{{ host.website }}">{{ host.website }}</a></div> + {% endif %} +</div> + +</body> +</html> diff --git a/program/templates/v2/host_list.html b/program/templates/v2/host_list.html new file mode 100644 index 0000000..ada9bf1 --- /dev/null +++ b/program/templates/v2/host_list.html @@ -0,0 +1,19 @@ +<html> +<head> + <title>Sendungsmacherinnen — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +<div id="content-main"> + <h1>Sendungsmachende A-Z</h1> + <div class="host-list"> + {% for host in host_list %} + <div class="host"> + <a href="{% url "host-detail" host.id %}">{{ host.name }}</a> + </div> + {% endfor %} + </div> +</div> + +</body> +</html> diff --git a/program/templates/v2/recommendation.html b/program/templates/v2/recommendation.html new file mode 100644 index 0000000..36b7c02 --- /dev/null +++ b/program/templates/v2/recommendation.html @@ -0,0 +1,28 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"/> + <title>Recomendations box</title> +</head> +<body> + <ul> +{% for recommendation in recommendation_list %} + <li class="bf-{{ recommendation.show.broadcastformat.slug }}"> + <div class="time">{{ recommendation.start|date:"d.m. H:i" }} - {{ recommendation.end|date:"H:i" }}</td> + <div class="show-name"> + <a href="{% url "timeslot-detail" recommendation.id %}">{{ recommendation.show.name }}</a> + </div> + <div class="show-content"> +{% if recommendation.note %} + {{ recommendation.note.title }} +{% else %} + {{ recommendation.show.short_description }} +{% endif %} + <br/> + <a href="{% url "timeslot-detail" recommendation.id %}">[weiter]</a> + </div> + </li> +{% endfor %} + </ul> +</body> +</html> diff --git a/program/templates/v2/recommendation_list.html b/program/templates/v2/recommendation_list.html new file mode 100644 index 0000000..3fcc5d1 --- /dev/null +++ b/program/templates/v2/recommendation_list.html @@ -0,0 +1,47 @@ +<html> +<head> + <title>Tipps — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +<div id="content-main" class="recommendations"> + <h1>Programmhinweise</h1> + <div id="shows"> + {% for recommendation in recommendation_list %} + <div class="show recommendation bf-{{ recommendation.show.broadcastformat.slug }}"> + <div class="show-abbrevs"> + {% for si in recommendation.show.showinformation.all %} + <span title="{{ si.information }}" + class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in recommendation.show.showtopic.all %} + <span title="{{ st.topic }}" + class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in recommendation.show.musicfocus.all %} + <span title="{{ mf.focus }}" + class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + <div class="show-detail"> + <h4> + <a href="{% url "show-detail" recommendation.show.slug %}">{{ recommendation.show.name }}</a><br/> + vom {{ recommendation.start|date:"d.m. H:i" }}-{{ recommendation.end|date:"H:i" }}</h4> + {% if recommendation.note %} + <h3 class="show-title"> + <a href="{% url "timeslot-detail" recommendation.id %}">{{ recommendation.note.title }}</a> + </h3> + <div class="note-content">{{ recommendation.note.content|safe }}</div> + {% else %} + <h3 class="show-title"><a + href="{% url "timeslot-detail" recommendation.id %}">{{ recommendation.show.broadcastformat.format }}</a> + </h3> + {% endif %} + </div> + </div> + {% endfor %} + </div> +</div> + +</body> +</html> diff --git a/program/templates/v2/show_detail.html b/program/templates/v2/show_detail.html new file mode 100644 index 0000000..2e45549 --- /dev/null +++ b/program/templates/v2/show_detail.html @@ -0,0 +1,88 @@ +<html> +<head> + <title>Sendung: {{ show.name }} — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +<div id="calendar"></div> + +<div id="content-main" class="show-detail"> + + <div class="show-detail-header bf-{{ show.broadcastformat.slug }}"> + <div class="show-details"> + <h1 id="name">{{ show.name }}</h1> + {% if show.id != 1 %} + <p id="programslots"> + {% for slot in show.active_programslots %} + <span class="programslot">{{ slot }}</span><br/> + {% endfor %} + </p> + {% endif %} + </div> + + <div class="show-categorization"> + <p id="broadcastformat">{{ show.broadcastformat.format }}</p> + {% for si in show.showinformation.all %} + <span title="{{ si.information }}" class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in show.showtopic.all %} + <span title="{{ st.topic }}" class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in show.musicfocus.all %} + <span title="{{ mf.focus }}" class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + + </div> + + <div id="short-description" class="documentDescription">{{ show.short_description }}</div> + + {% if show.description %} + <div id="description">{{ show.description|safe }}</div> + {% endif %} + + {% if show.image and show.image_enabled %} + <div id="image" style="float: right;"><img src="/program/static/{{ show.image }}" width="200" alt="image"></div> + {% endif %} + + <p> + {% for host in show.hosts.all %} + <a href="{% url "host-detail" host.id %}">{{ host }}</a><br/> + {% endfor %} + {% if show.email %} + <strong>Email:</strong> <a href="mailto:{{ show.email }}">{{ show.email }}</a><br/> + {% endif %} + {% if show.website %} + <strong>Website:</strong> <a href="{{ show.website }}">{{ show.website }}</a><br/> + {% endif %} + </p> + + {% if show.notes.all %} + <br/> + <h2>Sendungstipps</h2> + <ul class="recommendations-list"> + {% for note in show.notes.all reversed %} + <li> + <a href="{% url "timeslot-detail" note.timeslot.id %}" + title="{{ note.title }}">{{ note.start|date:"d. M Y" }}:</a> + <div class="title">{{ note.title }}</div> + </li> + {% endfor %} + {% if show.predecessor and show.predecessor.notes.all %} + {% if show.name != show.predecessor.name %} + <h3>Davor als <a href="{% url "show-detail" show.predecessor.slug %}">{{ show.predecessor.name }}</a></h3> + {% endif %} + {% for note in show.predecessor.notes.all reversed %} + <li> + <a href="{% url "timeslot-detail" note.timeslot.id %}" + title="{{ note.title }}">{{ note.start|date:"d. M Y" }}:</a> + <div class="title">{{ note.title }}</div> + </li> + {% endfor %} + {% endif %} + </ul> + {% endif %} +</div> + +</body> +</html> diff --git a/program/templates/v2/show_list.html b/program/templates/v2/show_list.html new file mode 100644 index 0000000..6d9d35d --- /dev/null +++ b/program/templates/v2/show_list.html @@ -0,0 +1,57 @@ +<html> +<head> + <title>Sendungen — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +{% load filters %} +<div id="filter-format"> + {% broadcastformatV2 %} +</div> +<div id="filter-topic"> + <dl id="filter-header" class="portlet"> + <dt class="portletHeader"><span>Filter</span></dt> + </dl> + {% musicfocusV2 %} + {% showinformationV2 %} + {% showtopicV2 %} + {% languageV2 %} +</div> + +<div id="content-main" class="show-list"> + <h1>Sendungen A-Z</h1> + + <div id="shows"> + {% for show in show_list %} + <div class="show bf-{{ show.broadcastformat.slug }}"> + <div class="show-abbrevs"> + {% for si in show.showinformation.all %} + <span title="{{ si.information }}" + class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in show.showtopic.all %} + <span title="{{ st.topic }}" + class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in show.musicfocus.all %} + <span title="{{ mf.focus }}" + class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + <div class="show-detail"> + <h3 class="show-title"><a href="{% url "show-detail" show.slug %}">{{ show.name }}</a></h3> + <ul class="show-programslots"> + {% for programslot in show.active_program_slots %} + <li class="show-programslot">{{ programslot }}</li> + {% endfor %} + </ul> + <p class="show-description">{{ show.short_description }}</p> + </div> + </div> + {% endfor %} + </div> + +</div> + +</body> +</html> diff --git a/program/templates/v2/timeslot_detail.html b/program/templates/v2/timeslot_detail.html new file mode 100644 index 0000000..88749a2 --- /dev/null +++ b/program/templates/v2/timeslot_detail.html @@ -0,0 +1,57 @@ +<html> +<head> + <title>Sendung: {{ timeslot.show.name }} — Radio Helsinki - Freies Radio Graz</title> +</head> +<body> + +<div id="content-main" class="timeslot-detail"> + + <div class="show-detail-header bf-{{ timeslot.show.broadcastformat.slug }}"> + <h1 id="name"> + <a href="{% url "show-detail" timeslot.show.slug %}">{{ timeslot.show.name }}</a> + </h1> + {% if timeslot.note %} + <h2>{{ timeslot.note.title }}</h2> + {% endif %} + <strong>Sendung am {{ timeslot.start|date:"d.m.Y H:i" }} bis {{ timeslot.end|date:"H:i" }}</strong> + + <div class="show-abbrevs"> + {% for si in timeslot.show.showinformation.all %} + <span title="{{ si.information }}" class="abbrev si-{{ si.abbrev }}"><span>{{ si.abbrev }}</span></span> + {% endfor %} + {% for st in timeslot.show.showtopic.all %} + <span title="{{ st.topic }}" class="abbrev st-{{ st.abbrev }}"><span>{{ st.abbrev }}</span></span> + {% endfor %} + {% for mf in timeslot.show.musicfocus.all %} + <span title="{{ mf.focus }}" class="abbrev mf-{{ mf.abbrev }}"><span>{{ mf.abbrev }}</span></span> + {% endfor %} + </div> + + <p id="broadcastformat">{{ timeslot.show.broadcastformat.format }}</p> + </div> + + {% if timeslot.note %} + <p class="timeslot-note">{{ timeslot.note.content|safe }}</p> + {% endif %} + + <div id="short-description" class="documentDescription">{{ timeslot.show.short_description }}</div> + + {% if timeslot.show.description %} + <div id="description">{{ timeslot.show.description|safe }}</div> + {% endif %} + + <p> + {% for host in timeslot.show.hosts.all %} + <a href="{% url "host-detail" host.id %}">{{ host }}</a><br/> + {% endfor %} + {% if timeslot.show.email %} + <strong>Email:</strong> <a href="mailto:{{ timeslot.show.email }}">{{ timeslot.show.email }}</a><br/> + {% endif %} + {% if timeslot.show.website %} + <strong>Website:</strong> <a href="{{ timeslot.show.website }}">{{ timeslot.show.website }}</a><br/> + {% endif %} + </p> +</div> + +</body> +</html> diff --git a/program/templatetags/filters.py b/program/templatetags/filters.py new file mode 100644 index 0000000..811216b --- /dev/null +++ b/program/templatetags/filters.py @@ -0,0 +1,30 @@ +from django import template + +from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Language + +register = template.Library() + + +@register.inclusion_tag('v2/filters/broadcastformat.html') +def broadcastformatV2(): + return {'broadcastformat_list': BroadcastFormat.objects.filter(enabled=True)} + + +@register.inclusion_tag('v2/filters/musicfocus.html') +def musicfocusV2(): + return {'musicfocus_list': MusicFocus.objects.all()} + + +@register.inclusion_tag('v2/filters/showinformation.html') +def showinformationV2(): + return {'showinformation_list': ShowInformation.objects.all()} + + +@register.inclusion_tag('v2/filters/showtopic.html') +def showtopicV2(): + return {'showtopic_list': ShowTopic.objects.all()} + + +@register.inclusion_tag('v2/filters/language.html') +def languageV2(): + return {'language_list': Language.objects.all()} diff --git a/program/urls.py b/program/urls.py index a3badf3..cb389e2 100644 --- a/program/urls.py +++ b/program/urls.py @@ -21,7 +21,18 @@ urlpatterns = patterns('', url(r'^shows/?$', views.ShowListView.as_view()), url(r'^shows/(?P<slug>[\w-]+)/?$', views.ShowDetailView.as_view(), name='show-detail'), url(r'^(?P<pk>\d+)/?$', views.TimeSlotDetailView.as_view(), name='timeslot-detail'), - url(r'^styles.css$', views.StylesView.as_view()) + url(r'^styles.css$', views.StylesView.as_view()), + # V2 Patterns for new Homepage 2021 + url(r'^v2/today/?$', views.DayScheduleViewV2.as_view()), + url(r'^v2/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', views.DayScheduleViewV2.as_view()), + url(r'^v2/current_box/?$', cache_page(60)(views.CurrentShowBoxViewV2.as_view())), + url(r'^v2/hosts/?$', views.HostListViewV2.as_view()), + url(r'^v2/hosts/(?P<pk>\d+)/?$', views.HostDetailViewV2.as_view(), name='host-detail'), + url(r'^v2/tips/?$', views.RecommendationsListViewV2.as_view()), + url(r'^v2/tips_box/?$', views.RecommendationsBoxViewV2.as_view()), + url(r'^v2/shows/?$', views.ShowListViewV2.as_view()), + url(r'^v2/shows/(?P<slug>[\w-]+)/?$', views.ShowDetailViewV2.as_view(), name='show-detail'), + url(r'^v2/(?P<pk>\d+)/?$', views.TimeSlotDetailViewV2.as_view(), name='timeslot-detail'), ) if settings.DEBUG: urlpatterns += \ diff --git a/program/views.py b/program/views.py index 256ad5d..2a7609c 100644 --- a/program/views.py +++ b/program/views.py @@ -13,6 +13,8 @@ from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, Sho from program.utils import tofirstdayinisoweek, get_cached_shows +# Legacy Views for Homepage until 2021 + class HostListView(ListView): context_object_name = 'host_list' queryset = Host.objects.filter(Q(is_always_visible=True) | Q(shows__programslots__until__gt=datetime.now)).distinct() @@ -195,6 +197,134 @@ class StylesView(TemplateView): return context +# V2 Views added for new Homepage 2021 + +class HostListViewV2(ListView): + context_object_name = 'host_list' + queryset = Host.objects.filter(Q(is_always_visible=True) | Q(shows__programslots__until__gt=datetime.now)).distinct() + template_name = 'v2/host_list.html' + + +class HostDetailViewV2(DetailView): + context_object_name = 'host' + queryset = Host.objects.all() + template_name = 'v2/host_detail.html' + + +class ShowListViewV2(ListView): + context_object_name = 'show_list' + template_name = 'v2/show_list.html' + + def get_queryset(self): + queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() + if 'broadcastformat' in self.request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + queryset = queryset.filter(broadcastformat=broadcastformat) + elif 'musicfocus' in self.request.GET: + musicfocus = get_object_or_404(MusicFocus, slug=self.request.GET['musicfocus']) + queryset = queryset.filter(musicfocus=musicfocus) + elif 'showinformation' in self.request.GET: + showinformation = get_object_or_404(ShowInformation, slug=self.request.GET['showinformation']) + queryset = queryset.filter(showinformation=showinformation) + elif 'showtopic' in self.request.GET: + showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic']) + queryset = queryset.filter(showtopic=showtopic) + elif 'language' in self.request.GET: + language = get_object_or_404(Language, slug=self.request.GET['language']) + queryset = queryset.filter(language=language) + + return queryset + + +class ShowDetailViewV2(DetailView): + queryset = Show.objects.all().exclude(id=1) + template_name = 'v2/show_detail.html' + + +class TimeSlotDetailViewV2(DetailView): + queryset = TimeSlot.objects.all() + template_name = 'v2/timeslot_detail.html' + + +class RecommendationsListViewV2(ListView): + context_object_name = 'recommendation_list' + template_name = 'v2/recommendation_list.html' + + now = datetime.now() + end = now + timedelta(weeks=1) + + queryset = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, + start__range=(now, end)) | + Q(show__broadcastformat__slug='sondersendung', + start__range=(now, end))).order_by('start')[:20] + + +class RecommendationsBoxViewV2(RecommendationsListViewV2): + template_name = 'v2/recommendation.html' + + +class CurrentShowBoxViewV2(TemplateView): + context_object_name = 'recommendation_list' + template_name = 'v2/current_show.html' + + def get_context_data(self, **kwargs): + current_timeslot = TimeSlot.objects.get_or_create_current() + previous_timeslot = current_timeslot.get_previous_by_start() + next_timeslot = current_timeslot.get_next_by_start() + after_next_timeslot = next_timeslot.get_next_by_start() + + context = super(CurrentShowBoxViewV2, self).get_context_data(**kwargs) + context['current_timeslot'] = current_timeslot + context['previous_timeslot'] = previous_timeslot + context['next_timeslot'] = next_timeslot + context['after_next_timeslot'] = after_next_timeslot + return context + + +class DayScheduleViewV2(TemplateView): + template_name = 'v2/day_schedule.html' + + def get_context_data(self, **kwargs): + year = self.kwargs.get('year', None) + month = self.kwargs.get('month', None) + day = self.kwargs.get('day', None) + + if year is None and month is None and day is None: + today = datetime.combine(date.today(), time(6, 0)) + else: + today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') + + tomorrow = today + timedelta(days=1) + + context = super(DayScheduleViewV2, self).get_context_data(**kwargs) + context['day'] = today + context['recommendations'] = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) + context['default_show'] = Show.objects.get(pk=1) + + timeslots = TimeSlot.objects.get_day_timeslots(today) + + if 'broadcastformat' in self.request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + context['timeslots'] = timeslots.filter(show__broadcastformat=broadcastformat) + elif 'musicfocus' in self.request.GET: + musicfocus = get_object_or_404(MusicFocus, slug=self.request.GET['musicfocus']) + context['timeslots'] = timeslots.filter(show__musicfocus=musicfocus) + elif 'showinformation' in self.request.GET: + showinformation = get_object_or_404(ShowInformation, slug=self.request.GET['showinformation']) + context['timeslots'] = timeslots.filter(show__showinformation=showinformation) + elif 'showtopic' in self.request.GET: + showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic']) + context['showtopic'] = timeslots.filter(show__showtopic=showtopic) + elif 'language' in self.request.GET: + language = get_object_or_404(Language, slug=self.request.GET['language']) + context['showtopic'] = timeslots.filter(show__language=language) + else: + context['timeslots'] = timeslots + return context + + +# Exports + def json_day_schedule(request, year=None, month=None, day=None): if year is None and month is None and day is None: today = datetime.combine(date.today(), time(0, 0)) |