Exemple #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))
Exemple #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))
def add_schedule():

    teams = TeamService.get_all()

    if request.method == 'GET':
        return render_template('admin/event/add_schedule.html', teams=teams)

    event_id = int(request.args.get('event_id'))

    schedule_dict = request.form.to_dict()
    schedule_dict['event_id'] = event_id
    MatchService.add(schedule_dict)

    return redirect(url_for('admin.list_match_schedules', event_id=event_id))
 def get_selected_match(match):
     display_order = match.display_order
     ex_selected_match_id = match.id
     match = MatchService.get_match_info(match.match_id)
     match['display_order'] = display_order
     match['ex_selected_match_id'] = ex_selected_match_id
     return match
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))
Exemple #6
0
def add_schedule():

    event_id = int(request.args.get('event_id'))
    teams = EventTeamService.get_all_by_event(event_id)

    if request.method == 'GET':
        return render_template('admin/event/add_schedule.html', 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.add(schedule_dict)

    return redirect(url_for('admin.list_match_schedules', event_id=event_id))
 def get_selected_match(match):
     match = MatchService.get_match_info(match.match_id)
     return match
 def get_match_info(match):
     match = MatchService.get_match_info(match.id)
     return match
def delete_schedule(schedule_id):
    MatchService.delete(schedule_id)
    return redirect(url_for('admin.list_match_schedules'))
 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
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'))
Exemple #12
0
def delete_schedule(schedule_id):
    MatchService.delete(schedule_id)
    return jsonify_with_data(APIError.OK)
Exemple #13
0
def hide_event_schedules(schedule_id):
    MatchService.hide(schedule_id)
    return jsonify_with_data((200, 'OK'))
Exemple #14
0
def show_event_schedules(schedule_id):
    MatchService.show(schedule_id)
    return jsonify_with_data((200, 'OK'))
 def get_match_info(match):
     match_id = match.id
     match = MatchService.get_match_info(match_id)
     match['isHaveLiveVideo'] = MatchService.isHaveLiveVideo(match_id)
     return match
Exemple #16
0
 def get(self, community):
     return {"matches": [m.serialize for m in MatchService.get_all(community)]}