Replace hard-coded meaning of rrule id/pk with something better
Currently, the generate_timeslots()
method in the Schedule
model doesn't belong there, but the real problem is that it uses the rrule.pk
to modify its behavior.
In a similar way the filter_active()
method in ShowFilterSet
uses the rrule.id
to filter the active shows.
The RRule
model was intended to be a simple wrapper around dateutil.rrule
and it is used to map its fields to the equivalent parameters of the the rrule()
constructor when creating timeslots for a schedule.
This behavior should only be based on the parameters of the underlying rrule
and not the id or
pkof the
RRule` object as these depend on the set of fixtures loaded or the configuration created for the radio station.
We should get rid of this.
We will need to add the by_week_days
field to the RRule
model, to have "business days" and "weekends" as a weekly recurrence.
All other recurrence rules can be distinguished from each other without using the id
or the pk
field:
name | freq | interval | by_set_pos | count | by_weekdays | notes |
---|---|---|---|---|---|---|
daily | 3 | |||||
weekly | 2 | 1 | ||||
business days | 2 | 1 | 0,1,2,3,4 | |||
weekends | 2 | 1 | 5,6 | |||
bi-weekly | 2 | 2 | ||||
four-weekly | 2 | 4 | ||||
monthly on the first | 1 | 1 | 1 | |||
monthly on the second | 1 | 1 | 2 | |||
monthly on the third | 1 | 1 | 3 | |||
monthly on the fourth | 1 | 1 | 4 | |||
monthly on the fifth | 1 | 1 | 5 | |||
monthly on the last | 1 | 1 | -1 | |||
bi-monthly | 1 | 2 | ||||
three-monthly | 1 | 3 | ||||
four-monthly | 1 | 4 | ||||
once | 0 | 1 |
freq=0 is actually yearly, but together with count=1 , it achieves what we want |
Also, we may need to add the by_week_no
field to the RRule
model, if we want to provide the recurrence rules "(biweekly) every odd-numbered week" and "(biweekly) ever even-numbered week". These are actually a "bi-weekly" recurrence rule, with a different first_date
.