Пример #1
0
def edit_schedule(schedule_id):
    event_id = request.args.get('event_id', 0)
    event_id = int(event_id)
    match = MatchService.get_one(schedule_id)
    teams = EventTeamService.get_all_by_event(event_id)
    default_tm = request.args.get('date')
    if request.method == 'GET':
        return render_template(
                                              'admin/event/edit_schedule.html',
                                              match=match, teams=teams)

    schedule_dict = {}

    schedule_dict['event_id'] = event_id
    schedule_dict['start_tm'] = request.form.get('start_tm')
    schedule_dict['status'] = request.form.get('status',type=int)
    schedule_dict['round'] = request.form.get('round',0,type=int)
    schedule_dict['brief'] = request.form.get('brief')
    schedule_dict['team1_id'] = request.form.get('team1_id')
    schedule_dict['team1_score'] = request.form.get('team1_score',0,type=int)
    schedule_dict['team2_id'] = request.form.get('team2_id')
    schedule_dict['team2_score'] = request.form.get('team2_score',0,type=int)

    MatchService.edit(schedule_id, schedule_dict)

    return redirect(url_for('admin.list_match_schedules', event_id=event_id,date=default_tm))
Пример #2
0
def add_forecast(match_id):

    event_id = request.args.get('event_id', 0)
    event_id = int(event_id)
    match = MatchService.get_one(match_id)
    default_tm = request.args.get('date')
    if request.method == 'GET':
        return render_template('admin/event/add_forecast.html', match=match)

    match_dict = request.form.to_dict()
    MatchService.edit(match_id, match_dict)

    return redirect(url_for('admin.list_hot_matches', event_id=event_id,date=default_tm))
Пример #3
0
def edit_schedule(schedule_id):
    event_id = request.args.get('event_id', 0)
    event_id = int(event_id)
    match = MatchService.get_one(schedule_id)
    teams = TeamService.get_all()
    default_tm = request.args.get('date')
    if request.method == 'GET':
        return render_template('admin/event/edit_schedule.html',
                               match=match,
                               teams=teams)

    schedule_dict = request.form.to_dict()
    MatchService.edit(schedule_id, schedule_dict)

    return redirect(
        url_for('admin.list_match_schedules',
                event_id=event_id,
                date=default_tm))
def relate_resource(resource_id):

    resource = PendingVideoService.get_one(resource_id)
    tmp = json.loads(resource['data'])
    if request.method == 'GET':
        if tmp['tags']:
            tags = list(set(tmp['tags']))
            lable = [s.split(';')[1] for s in tags]
        else:
            lable = []
        resource['lable'] = '/'.join(lable)
        events = ChannelService.get_all(type='football')
        programs = ProgramService.get_simple_all()

        return render_template('admin/media/relate.html',
                               events=events,
                               programs=programs,
                               resource=resource)

    type = request.form.get('type')
    isvr = request.form.get('isvr', 0, int)

    args_dict = {}
    args_dict['cid'] = tmp['cid']
    args_dict['size'] = tmp['size']
    args_dict = json.dumps(args_dict)

    if type == 'event_video':
        event_id = int(request.form.get('event_id'))
        # add to eventnews table
        EventNewsService.add(event_id, 'video', 'bfonline', '暴风体育',
                             tmp['title'], isvr, tmp['image'], '',
                             tmp['play_code'], tmp['play_code'], '', '',
                             args_dict, resource['created_at'])
    elif type == 'program':
        program_id = request.form.get('program_id')
        # add to program post table
        ProgramPostService.add(program_id, tmp['title'], isvr, 'bfonline',
                               '暴风体育', '', tmp['image'], '', tmp['play_code'],
                               tmp['play_code'], resource['created_at'],
                               args_dict)
    elif type == 'olympic':
        OGVideoService.add(tmp['title'], isvr, 'highlight', 'bfonline',
                           tmp['duration'], tmp['image'], '', tmp['play_code'],
                           args_dict, resource['created_at'])
    else:
        try:
            match_id = request.form.get('match_id')
        except:
            raise InvalidArgument()

        match = MatchService.get_one(match_id)
        if not match:
            raise NotFound()

        if type == 'match_video':
            MatchNewsService.add(match_id, 'video', 'bfonline', '暴风体育',
                                 tmp['title'], isvr, tmp['image'], '',
                                 tmp['play_code'], tmp['play_code'], '', '',
                                 args_dict, resource['created_at'])
        else:
            MatchVideoService.add(match_id, tmp['title'], isvr, type,
                                  'bfonline', tmp['duration'], tmp['image'],
                                  '', tmp['play_code'], tmp['play_code'],
                                  args_dict, resource['created_at'])

    PendingVideoService.relate(resource_id)

    return redirect(url_for('admin.list_resources'))