diff options
-rw-r--r-- | program/views.py | 7 | ||||
-rw-r--r-- | templates/program/boxes/recommendations.html | 28 |
2 files changed, 23 insertions, 12 deletions
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 @@ <td class="format bf-{{ item.show.broadcastformat.slug }}" title="{{ item.show.broadcastformat.format }}"> </td> <td class="show"> - {{ item.timeslot.start|date:"d.m. H:i" }} - - {{ item.timeslot.end|date:"H:i" }}<br /> + {{ item.start|date:"d.m. H:i" }} - + {{ item.end|date:"H:i" }}<br /> - <h3> - <a href="{% url timeslot-detail item.timeslot.id %}">{{ item.show.name }}</a> - </h3> - <p class="note-title"> - {{ item.title }}<br /> - <a href="{% url timeslot-detail item.timeslot.id %}">[weiter]</a> - </p> + {% if item.note %} + <h3> + <a href="{% url timeslot-detail item.id %}">{{ item.show.name }}</a> + </h3> + <p class="note-title"> + {{ item.note.title }}<br /> + <a href="{% url timeslot-detail item.id %}">[weiter]</a> + </p> + {% else %} + <h3> + <a href="{% url show-detail item.show.slug %}">{{ item.show.name }}</a> + </h3> + <p class="note-title"> + {{ item.show.broadcastformat.format }}<br /> + <a href="{% url show-detail item.show.slug %}">[weiter]</a> + </p> + {% endif %} </td> </tr> {% endfor %} |