def make_schedule_array(event):
"""
Convert an event's schedules into a schedule_array
"""
# Since the schedules in the event are time-fixed, events with multiple
# times will have the same start_date, rrule and place combination
# This groups the times according to the start_date/rrule combination
# {
# (<start_date>, "<rrule>", <place>): [<start_time>, ]
# }
schedules = OrderedDict()
for s in event.dates.all().order_by("start_date", "start_time"):
key = (s.start_date, s.rrule, s.place, s.more_info_url)
if key in schedules:
schedules[key].append((s.start_time, s.duration))
else:
schedules[key] = [(s.start_time, s.duration), ]
return schedules
评论列表
文章目录