def list_discuss_matches():
    event_id = request.args.get('event_id', 0)
    event_id = int(event_id)
    default_tm = request.args.get('date')
    if not default_tm:
        default_tm = timestamp_to_datetime(date_to_timestamp(date.today()))
    else:
        string_to_tm = datetime.strptime(default_tm, "%Y-%m-%d")
        default_tm = string_to_tm

    # get match info
    def get_match_info(match):
        match = MatchService.get_match_info(match.id)
        return match

    # all finished matches
    match_list = EventService.get_all(event_id=event_id,
                                      status=MatchStatus.FINISHED,
                                      default_tm=default_tm)
    matches = map(get_match_info, match_list)

    # get selected match info
    def get_selected_match(match):
        match = MatchService.get_match_info(match.match_id)
        return match

    # selected matches
    selected_match_list = SelectedMatchService.get_all(event_id=event_id,
                                                       type='discuss')
    selected_matches = map(get_selected_match, selected_match_list)

    # calendar finished matches
    schedule_list = EventService.get_all(event_id=event_id,
                                         status=MatchStatus.FINISHED)

    #  get match format date
    def get_format_date(match):
        match_tm = match.start_tm.strftime('%Y-%m-%d')
        return match_tm

    format_schedules = map(get_format_date, schedule_list)

    calendar_list = sorted(set(format_schedules), key=format_schedules.index)

    def get_calendar_date(match):
        string_to_tm = datetime.strptime(match, "%Y-%m-%d")
        cn_date = to_cn_date(string_to_tm)
        schedule = {}
        schedule['id'] = match
        schedule['date'] = cn_date
        return schedule

    schedules = map(get_calendar_date, calendar_list)

    return render_template('admin/event/discuss_list.html',
                           event_id=event_id,
                           matches=matches,
                           schedules=schedules,
                           selected_matches=selected_matches)
Example #2
0
def list_schedules():

    event_id = request.args.get('event_id', 0)
    event_id = int(event_id)
    default_tm = request.args.get('date')
    if not default_tm:
        default_tm = timestamp_to_datetime(date_to_timestamp(date.today()))
    else:
        string_to_tm = datetime.strptime(
            default_tm, "%Y-%m-%d")
        default_tm = string_to_tm

    # get match info
    def get_match_info(match):
        lives = MatchLiveService.get_all(match_id=match.id)
        match = MatchService.get_match_info(match.id)
        match['lives'] = lives
        return match

    # all matches
    match_list = EventService.get_all(event_id=event_id, default_tm=default_tm)
    matches = map(get_match_info, match_list)

    # calendar finished matches
    schedule_list = EventService.get_all(event_id=event_id)

    #  get match format date
    def get_format_date(match):
        match_tm = match.start_tm.strftime('%Y-%m-%d')
        return match_tm

    format_schedules = map(get_format_date, schedule_list)

    calendar_list = sorted(set(format_schedules), key=format_schedules.index)

    def get_calendar_date(match):
        string_to_tm = datetime.strptime(
            match, "%Y-%m-%d")
        cn_date = to_cn_date(string_to_tm)
        schedule = {}
        schedule['id'] = match
        schedule['date'] = cn_date
        return schedule
    schedules = map(get_calendar_date, calendar_list)

    sites = SiteService.get_all()

    return render_template(
                                          'admin/event/schedule_list.html',
                                          event_id=event_id,
                                          sites=sites,
                                          matches=matches,
                                          sDate=default_tm,
                                          schedules=schedules)
Example #3
0
def list_olympics_schedules():

    default_tm = request.args.get('date')
    if not default_tm:
        default_tm = timestamp_to_datetime(date_to_timestamp(date.today()))
    else:
        string_to_tm = datetime.strptime(
            default_tm, "%Y-%m-%d")
        default_tm = string_to_tm

    schedules = [
        {'date': (u'星期二', '8-2'), 'id': '2016-08-02'},
        {'date': (u'星期三', '8-3'), 'id': '2016-08-03'},
        {'date': (u'星期四', '8-4'), 'id': '2016-08-04'},
        {'date': (u'星期五', '8-5'), 'id': '2016-08-05'},
        {'date': (u'星期六', '8-6'), 'id': '2016-08-06'},
        {'date': (u'星期日', '8-7'), 'id': '2016-08-07'},
        {'date': (u'星期一', '8-8'), 'id': '2016-08-08'},
        {'date': (u'星期二', '8-9'), 'id': '2016-08-09'},
        {'date': (u'星期三', '8-10'), 'id': '2016-08-10'},
        {'date': (u'星期四', '8-11'), 'id': '2016-08-11'},
        {'date': (u'星期五', '8-12'), 'id': '2016-08-12'},
        {'date': (u'星期六', '8-13'), 'id': '2016-08-13'},
        {'date': (u'星期日', '8-14'), 'id': '2016-08-14'},
        {'date': (u'星期一', '8-15'), 'id': '2016-08-15'},
        {'date': (u'星期二', '8-16'), 'id': '2016-08-16'},
        {'date': (u'星期三', '8-17'), 'id': '2016-08-17'},
        {'date': (u'星期四', '8-18'), 'id': '2016-08-18'},
        {'date': (u'星期五', '8-19'), 'id': '2016-08-19'},
        {'date': (u'星期六', '8-20'), 'id': '2016-08-20'},
        {'date': (u'星期日', '8-21'), 'id': '2016-08-21'},
    ]

    matches = OGScheduleService.get_all(default_tm)

    return render_template(
        'admin/olympics/schedule/schedule_list.html',
        matches=matches,
        sDate=default_tm.strftime('%Y-%m-%d'),
        schedules=schedules)