summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-03-12 13:59:07 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-03-12 13:59:07 (GMT)
commit235719f0621b5e36d877d76cfaf40cdb43033a6e (patch)
tree270d1273375dab2f54649a4e31ba774aca0e93d9 /program
parent9b954d276cd226d470b670e757fe20dcbe36a4af (diff)
fixed display and generation of time slot for daily recurrences.
Diffstat (limited to 'program')
-rw-r--r--program/models.py46
1 files changed, 32 insertions, 14 deletions
diff --git a/program/models.py b/program/models.py
index 4849fe8..74f660a 100644
--- a/program/models.py
+++ b/program/models.py
@@ -167,7 +167,11 @@ class ProgramSlot(models.Model):
tstart = self.tstart.strftime('%H:%M')
until = self.until.strftime('%d. %b %Y')
- return u'%s, %s, %s - %s, %s - %s' % (self.rrule, weekday, tstart, tend, dstart, until)
+ if self.rrule.freq == 3:
+ # don't include weekday if frequency is daily
+ return u'%s, %s - %s, %s - %s' % (self.rrule, tstart, tend, dstart, until)
+ else:
+ return u'%s, %s, %s - %s, %s - %s' % (self.rrule, weekday, tstart, tend, dstart, until)
def save(self, *args, **kwargs):
if not self.pk:
@@ -178,18 +182,31 @@ class ProgramSlot(models.Model):
else:
byweekday = self.byweekday
- starts = list(rrule(freq=self.rrule.freq,
- dtstart=datetime.combine(self.dstart, self.tstart),
- interval=self.rrule.interval,
- until=self.until+relativedelta(days=+1),
- bysetpos=self.rrule.bysetpos,
- byweekday=self.byweekday))
- ends = list(rrule(freq=self.rrule.freq,
- dtstart=datetime.combine(self.dstart, self.tend),
- interval=self.rrule.interval,
- until=self.until+relativedelta(days=+1),
- bysetpos=self.rrule.bysetpos,
- byweekday=byweekday))
+ if self.rrule.freq == 3:
+ # don't include byweekday in the recurrence rule if the frequency is daily
+ starts = list(rrule(freq=self.rrule.freq,
+ dtstart=datetime.combine(self.dstart, self.tstart),
+ interval=self.rrule.interval,
+ until=self.until+relativedelta(days=+1),
+ bysetpos=self.rrule.bysetpos))
+ ends = list(rrule(freq=self.rrule.freq,
+ dtstart=datetime.combine(self.dstart, self.tend),
+ interval=self.rrule.interval,
+ until=self.until+relativedelta(days=+1),
+ bysetpos=self.rrule.bysetpos))
+ else:
+ starts = list(rrule(freq=self.rrule.freq,
+ dtstart=datetime.combine(self.dstart, self.tstart),
+ interval=self.rrule.interval,
+ until=self.until+relativedelta(days=+1),
+ bysetpos=self.rrule.bysetpos,
+ byweekday=self.byweekday))
+ ends = list(rrule(freq=self.rrule.freq,
+ dtstart=datetime.combine(self.dstart, self.tend),
+ interval=self.rrule.interval,
+ until=self.until+relativedelta(days=+1),
+ bysetpos=self.rrule.bysetpos,
+ byweekday=byweekday))
for k in range(len(starts)):
time_slot = TimeSlot(program_slot=self, start=starts[k], end=ends[k])
@@ -239,4 +256,5 @@ class Note(models.Model):
verbose_name_plural = _("Notes")
def __unicode__(self):
- return u'%s - %s' % (self.title, self.time_slot) \ No newline at end of file
+ return u'%s - %s' % (self.title, self.time_slot)
+ \ No newline at end of file