utils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:django-happenings 作者: natgeosociety 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号