From 55b2560b6180addea5d8b16e4dd4f80314fd7e09 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 15 Feb 2012 22:35:57 +0100 Subject: show specials as recommendations even if there is no note attached diff --git a/program/views.py b/program/views.py index c3d1b03..83a5994 100644 --- a/program/views.py +++ b/program/views.py @@ -1,5 +1,6 @@ from django.views.generic import list_detail, simple from django.shortcuts import get_object_or_404 +from django.db.models import Q from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot @@ -29,10 +30,10 @@ def show_list(request): def recommendations(request, template_name='program/recommendations.html'): now = datetime.now() - in_one_week = now + timedelta(weeks=1) - - queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:20] + 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] return list_detail.object_list(request, queryset=queryset, template_name=template_name, template_object_name='recommendation') def day_schedule(request, year=None, month=None, day=None): diff --git a/templates/program/boxes/recommendations.html b/templates/program/boxes/recommendations.html index 2b92a70..a0dd4b2 100644 --- a/templates/program/boxes/recommendations.html +++ b/templates/program/boxes/recommendations.html @@ -16,16 +16,26 @@   - {{ item.timeslot.start|date:"d.m. H:i" }} - - {{ item.timeslot.end|date:"H:i" }}
+ {{ item.start|date:"d.m. H:i" }} - + {{ item.end|date:"H:i" }}
-

- {{ item.show.name }} -

-

- {{ item.title }}
- [weiter] -

+ {% if item.note %} +

+ {{ item.show.name }} +

+

+ {{ item.note.title }}
+ [weiter] +

+ {% else %} +

+ {{ item.show.name }} +

+

+ {{ item.show.broadcastformat.format }}
+ [weiter] +

+ {% endif %} {% endfor %} -- cgit v0.10.2