diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2014-03-07 19:09:16 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2014-03-07 19:09:16 (GMT) |
commit | a1e6deb0bf70944a70111c41438456abe2f867e3 (patch) | |
tree | 4ce1741a8097e1a26fcced7c07f593995cd3ec70 /program | |
parent | 2638a34a18673c48c6bdbf31b057bbcf03c6aed2 (diff) |
fixed day_schedule to export 00:00 - 23:59:59 and not between 06:00 and 05:59
also added show name to json export
Diffstat (limited to 'program')
-rw-r--r-- | program/models.py | 6 | ||||
-rw-r--r-- | program/views.py | 14 |
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 |