From ed2890927d79792e9222f61c19969352b614da8f Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 18 Jun 2011 20:43:30 +0200 Subject: fixed week view. diff --git a/program/templatetags/timeslots.py b/program/templatetags/timeslots.py new file mode 100644 index 0000000..9b83a80 --- /dev/null +++ b/program/templatetags/timeslots.py @@ -0,0 +1,22 @@ +from django import template + +register = template.Library() + +from datetime import datetime, time, timedelta + +@register.simple_tag +def duration(start, end): + return 'style="height: %dpx"' % ((end-start).seconds/60) + +@register.simple_tag +def duration_until(end): + start = datetime.combine(end.date(), time(6,0)) + return 'style="height: %dpx"' % ((end-start).seconds/60) + +@register.simple_tag +def duration_since(start): + if start.time()
- -
 
+
+
 
+
06:00
+
07:00
+
08:00
+
09:00
+
10:00
+
11:00
+
12:00
+
13:00
+
14:00
+
15:00
+
16:00
+
17:00
+
18:00
+
19:00
+
20:00
+
21:00
+
22:00
+
23:00
+
00:00
+
01:00
+
02:00
+
03:00
+
04:00
+
05:00
+

{{ monday|date:"l d.m.Y" }}

{% for timeslot in monday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}

{{ tuesday|date:"l d.m.Y" }}

{% for timeslot in tuesday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}

{{ wednesday|date:"l d.m.Y" }}

{% for timeslot in wednesday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}

{{ thursday|date:"l d.m.Y" }}

{% for timeslot in thursday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}

{{ friday|date:"l d.m.Y" }}

{% for timeslot in friday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}

{{ saturday|date:"l d.m.Y" }}

{% for timeslot in saturday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}

{{ sunday|date:"l d.m.Y" }}

{% for timeslot in sunday_timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
- {{ default_show.name }} -
- {% endif %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
- {{ default_show.name }} -
- {% endif %} + {% include "program/week_schedule_timeslot.html" %} {% endfor %}
diff --git a/templates/program/week_schedule_timeslot.html b/templates/program/week_schedule_timeslot.html new file mode 100644 index 0000000..7b0f800 --- /dev/null +++ b/templates/program/week_schedule_timeslot.html @@ -0,0 +1,21 @@ +{% load timeslots %} + +{% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} +
+{{ default_show.name }} +
+{% endif %} + +{% if timeslot.end != timeslot.get_next_by_start.start %} + {% if not forloop.last %} +
+{{ default_show.name }} +
+ {% else %} +
+{{ default_show.name }} +
+ {% endif %} +{% endif %} -- cgit v0.10.2