summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--program/models.py6
-rw-r--r--program/views.py14
2 files changed, 13 insertions, 7 deletions
diff --git a/program/models.py b/program/models.py
index 89e2fa7..7cdc345 100644
--- a/program/models.py
+++ b/program/models.py
@@ -419,6 +419,12 @@ class TimeSlotManager(models.Manager):
return TimeSlot.objects.filter(models.Q(start__lte=today, end__gte=today) |
models.Q(start__gt=today, start__lt=tomorrow)).exclude(end=today)
+ def get_24h_timeslots(self, start):
+ end = start + timedelta(hours=24)
+
+ return TimeSlot.objects.filter(models.Q(start__lte=start, end__gte=start) |
+ models.Q(start__gt=start, start__lt=end)).exclude(end=start)
+
class TimeSlot(models.Model):
programslot = models.ForeignKey(ProgramSlot, related_name='timeslots', verbose_name=_("Program slot"))
start = models.DateTimeField(_("Start time"), unique=True)
diff --git a/program/views.py b/program/views.py
index 200d641..49bcd57 100644
--- a/program/views.py
+++ b/program/views.py
@@ -132,21 +132,21 @@ def styles(request):
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(6, 0))
+ today = datetime.combine(date.today(), time(0, 0))
else:
- today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M')
+ today = datetime.strptime('%s__%s__%s__00__00' % (year, month, day), '%Y__%m__%d__%H__%M')
- timeslots = TimeSlot.objects.get_day_timeslots(today)
+ timeslots = TimeSlot.objects.get_24h_timeslots(today)
schedule = []
for ts in timeslots:
if ts.programslot.automation_id:
- schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.automation_id))
+ schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, ts.programslot.automation_id))
elif ts.programslot.show.automation_id:
- schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.automation_id))
+ schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, ts.programslot.show.automation_id))
else:
- schedule.append((ts.start.strftime('%H:%M:%S'), -1))
+ schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, -1))
- return HttpResponse(json.dumps(schedule), content_type="application/json")
+ return HttpResponse(json.dumps(schedule), content_type="application/json; charset=utf-8")
def tofirstdayinisoweek(year, week):
# http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python