From 3f935fe643fd8d4f807803c99dbd25d048acb143 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 24 Feb 2021 15:42:40 +0100 Subject: add V2 views and template tags for new homepage diff --git a/program/templates/v2/boxes/broadcastformat.html b/program/templates/v2/boxes/broadcastformat.html new file mode 100644 index 0000000..8118cdb --- /dev/null +++ b/program/templates/v2/boxes/broadcastformat.html @@ -0,0 +1,11 @@ +{% if broadcastformat_list %} +
+
Legende
+ {% for bf in broadcastformat_list %} +
+ {{ bf.format }} +
+ {% endfor %} +
+{% endif %} diff --git a/program/templates/v2/boxes/current.html b/program/templates/v2/boxes/current.html new file mode 100644 index 0000000..0ac5179 --- /dev/null +++ b/program/templates/v2/boxes/current.html @@ -0,0 +1,65 @@ + + + + + Current program box + + +{% if previous_timeslot or current_timeslot or next_timeslot or after_next_timeslot %} +
+
Programm derzeit
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
{{ previous_timeslot.start|date:"H:i" }}  +

+ {{ previous_timeslot.show.name }} +

+
{{ current_timeslot.start|date:"H:i" }} +

+ {{ current_timeslot.show.name }} +

+ {% if current_timeslot.note %} +

{{ current_timeslot.note.title }}

+ {% else %} +

{{ current_timeslot.show.short_description }}

+ {% endif %} +
{{ next_timeslot.start|date:"H:i" }}  +

{{ next_timeslot.show.name }} +

+
{{ after_next_timeslot.start|date:"H:i" }}  +

+ {{ after_next_timeslot.show.name }} +

+
+
+
+{% endif %} + + diff --git a/program/templates/v2/boxes/language.html b/program/templates/v2/boxes/language.html new file mode 100644 index 0000000..050c342 --- /dev/null +++ b/program/templates/v2/boxes/language.html @@ -0,0 +1,15 @@ +{% if language_list %} +
+
Sprache
+
+ +
+
+{% endif %} diff --git a/program/templates/v2/boxes/musicfocus.html b/program/templates/v2/boxes/musicfocus.html new file mode 100644 index 0000000..021185b --- /dev/null +++ b/program/templates/v2/boxes/musicfocus.html @@ -0,0 +1,15 @@ +{% if musicfocus_list %} +
+
Musiktendenz
+
+
    + {% for mf in musicfocus_list %} +
  • + {{ mf.focus }} +
  • + {% endfor %} +
+
+
+{% endif %} diff --git a/program/templates/v2/boxes/recommendation.html b/program/templates/v2/boxes/recommendation.html new file mode 100644 index 0000000..3f4429e --- /dev/null +++ b/program/templates/v2/boxes/recommendation.html @@ -0,0 +1,39 @@ + + + + + Recomendations box + + +{% if recommendation_list %} +
+
Programmhinweise
+
+ + {% for recommendation in recommendation_list %} + + + + + + {% endfor %} +
   + {{ recommendation.start|date:"d.m. H:i" }} - {{ recommendation.end|date:"H:i" }}
+

+ {{ recommendation.show.name }} +

+

+ {% if recommendation.note %} + {{ recommendation.note.title }}
+ {% else %} + {{ recommendation.show.broadcastformat.format }}
+ {% endif %} + [weiter] +

+
+
+
+{% endif %} + + diff --git a/program/templates/v2/boxes/showinformation.html b/program/templates/v2/boxes/showinformation.html new file mode 100644 index 0000000..dbbe60d --- /dev/null +++ b/program/templates/v2/boxes/showinformation.html @@ -0,0 +1,16 @@ +{% if showinformation_list %} +
+
Sendungsinfo
+
+ +
+
+{% endif %} diff --git a/program/templates/v2/boxes/showtopic.html b/program/templates/v2/boxes/showtopic.html new file mode 100644 index 0000000..93e873a --- /dev/null +++ b/program/templates/v2/boxes/showtopic.html @@ -0,0 +1,16 @@ +{% if showtopic_list %} +
+
Thema / Schwerpunkt
+
+ +
+
+{% endif %} diff --git a/program/templates/v2/day_schedule.html b/program/templates/v2/day_schedule.html new file mode 100644 index 0000000..7bab98e --- /dev/null +++ b/program/templates/v2/day_schedule.html @@ -0,0 +1,101 @@ + + + Tagesansicht {{ day|date:"l, d.m.Y" }} — Radio Helsinki - Freies Radio Graz + + + +{% load content_boxes %} +
+ {% broadcastformatV2 %} +
+ +
+
+
Filter
+
+{% musicfocusV2 %} +{% showinformationV2 %} +{% showtopicV2 %} +{% languageV2 %} +
+ +
+

Tagesansicht

+

{{ day|date:"l, d.m.Y" }}

+ +
+ {% for timeslot in timeslots %} + {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} +
+
{{ timeslot.get_previous_by_start.end|date:"H:i" }}
+
+ {% for si in default_show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in default_show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in default_show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

{{ default_show.name }}

+

{{ default_show.short_description }}

+
+
+ {% endif %} +
+
{{ timeslot.start|date:"H:i" }}
+
+ {% for si in timeslot.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in timeslot.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in timeslot.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

{{ timeslot.show.name }}

+ {% if timeslot.note %} +

Heute: {{ timeslot.note.title }}

+ {% else %} +

{{ timeslot.show.short_description }}

+ {% endif %} +
+
+ {% if timeslot.end != timeslot.get_next_by_start.start %} +
+
{{ timeslot.end|date:"H:i" }}
+
+ {% for si in default_show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in default_show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in default_show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

{{ default_show.name }}

+

{{ default_show.short_description }}

+
+
+ {% endif %} + {% endfor %} +
+
+ + + 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 @@ + + + Host: {{ host.name }} — Radio Helsinki - Freies Radio Graz + + + +
+
{{ host.name }}
+ +
+
Sendungen
+ {% for show in host.active_shows %} + + {% endfor %} +
+ + {% if host.email %} +
E-Mail Adresse: {{ host.email }}
+ {% endif %} + + {% if host.website %} + + {% endif %} +
+ + + 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 @@ + + + Sendungsmacherinnen — Radio Helsinki - Freies Radio Graz + + + +
+

Sendungsmachende A-Z

+
+ {% for host in host_list %} + + {% endfor %} +
+
+ + + 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 @@ + + + Tipps — Radio Helsinki - Freies Radio Graz + + + +
+

Programmhinweise

+
+ {% for recommendation in recommendation_list %} +
+
+ {% for si in recommendation.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in recommendation.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in recommendation.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

+ {{ recommendation.show.name }}
+ vom {{ recommendation.start|date:"d.m. H:i" }}-{{ recommendation.end|date:"H:i" }}

+ {% if recommendation.note %} +

+ {{ recommendation.note.title }} +

+
{{ recommendation.note.content|safe }}
+ {% else %} +

{{ recommendation.show.broadcastformat.format }} +

+ {% endif %} +
+
+ {% endfor %} +
+
+ + + 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 @@ + + + Sendung: {{ show.name }} — Radio Helsinki - Freies Radio Graz + + + +
+ +
+ +
+
+

{{ show.name }}

+ {% if show.id != 1 %} +

+ {% for slot in show.active_programslots %} + {{ slot }}
+ {% endfor %} +

+ {% endif %} +
+ +
+

{{ show.broadcastformat.format }}

+ {% for si in show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+ +
+ +
{{ show.short_description }}
+ + {% if show.description %} +
{{ show.description|safe }}
+ {% endif %} + + {% if show.image and show.image_enabled %} +
image
+ {% endif %} + +

+ {% for host in show.hosts.all %} + {{ host }}
+ {% endfor %} + {% if show.email %} + Email: {{ show.email }}
+ {% endif %} + {% if show.website %} + Website: {{ show.website }}
+ {% endif %} +

+ + {% if show.notes.all %} +
+

Sendungstipps

+ + {% endif %} +
+ + + diff --git a/program/templates/v2/show_list.html b/program/templates/v2/show_list.html new file mode 100644 index 0000000..1115a41 --- /dev/null +++ b/program/templates/v2/show_list.html @@ -0,0 +1,57 @@ + + + Sendungen — Radio Helsinki - Freies Radio Graz + + + +{% load content_boxes %} +
+ {% broadcastformatV2 %} +
+
+
+
Filter
+
+ {% musicfocusV2 %} + {% showinformationV2 %} + {% showtopicV2 %} + {% languageV2 %} +
+ +
+

Sendungen A-Z

+ +
+ {% for show in show_list %} +
+
+ {% for si in show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

{{ show.name }}

+
    + {% for programslot in show.active_program_slots %} +
  • {{ programslot }}
  • + {% endfor %} +
+

{{ show.short_description }}

+
+
+ {% endfor %} +
+ +
+ + + 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 @@ + + + Sendung: {{ timeslot.show.name }} — Radio Helsinki - Freies Radio Graz + + + +
+ +
+

+ {{ timeslot.show.name }} +

+ {% if timeslot.note %} +

{{ timeslot.note.title }}

+ {% endif %} + Sendung am {{ timeslot.start|date:"d.m.Y H:i" }} bis {{ timeslot.end|date:"H:i" }} + +
+ {% for si in timeslot.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in timeslot.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in timeslot.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+ +

{{ timeslot.show.broadcastformat.format }}

+
+ + {% if timeslot.note %} +

{{ timeslot.note.content|safe }}

+ {% endif %} + +
{{ timeslot.show.short_description }}
+ + {% if timeslot.show.description %} +
{{ timeslot.show.description|safe }}
+ {% endif %} + +

+ {% for host in timeslot.show.hosts.all %} + {{ host }}
+ {% endfor %} + {% if timeslot.show.email %} + Email: {{ timeslot.show.email }}
+ {% endif %} + {% if timeslot.show.website %} + Website: {{ timeslot.show.website }}
+ {% endif %} +

+
+ + + diff --git a/program/templatetags/content_boxes.py b/program/templatetags/content_boxes.py index ece466b..f979ca2 100644 --- a/program/templatetags/content_boxes.py +++ b/program/templatetags/content_boxes.py @@ -5,6 +5,8 @@ from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTop register = template.Library() +# Legacy Tags for Homepage until 2021 + @register.inclusion_tag('boxes/broadcastformat.html') def broadcastformat(): return {'broadcastformat_list': BroadcastFormat.objects.filter(enabled=True)} @@ -28,3 +30,30 @@ def showtopic(): @register.inclusion_tag('boxes/language.html') def language(): return {'language_list': Language.objects.all()} + + +# V2 Tags added for new Homepage 2021 + +@register.inclusion_tag('v2/boxes/broadcastformat.html') +def broadcastformatV2(): + return {'broadcastformat_list': BroadcastFormat.objects.filter(enabled=True)} + + +@register.inclusion_tag('v2/boxes/musicfocus.html') +def musicfocusV2(): + return {'musicfocus_list': MusicFocus.objects.all()} + + +@register.inclusion_tag('v2/boxes/showinformation.html') +def showinformationV2(): + return {'showinformation_list': ShowInformation.objects.all()} + + +@register.inclusion_tag('v2/boxes/showtopic.html') +def showtopicV2(): + return {'showtopic_list': ShowTopic.objects.all()} + + +@register.inclusion_tag('v2/boxes/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[\w-]+)/?$', views.ShowDetailView.as_view(), name='show-detail'), url(r'^(?P\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\d{4})/(?P\d{1,2})/(?P\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\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[\w-]+)/?$', views.ShowDetailViewV2.as_view(), name='show-detail'), + url(r'^v2/(?P\d+)/?$', views.TimeSlotDetailViewV2.as_view(), name='timeslot-detail'), ) if settings.DEBUG: urlpatterns += \ diff --git a/program/views.py b/program/views.py index 256ad5d..ab7bd82 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(RecommendationsListView): + template_name = 'v2/boxes/recommendation.html' + + +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 + + +class CurrentShowBoxViewV2(TemplateView): + context_object_name = 'recommendation_list' + template_name = 'v2/boxes/current.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 + + +# 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)) -- cgit v0.10.2