def list_new_channels(): if request.method == 'GET': channels = NewChannelService.get_filter_all() events = ChannelService.get_all() eventsName = {} for item in events: eventsName[item['id']] = item['name'] return render_template('admin/channel/channel_list.html', eventName=eventsName, events=events, channels=channels) name = request.form.get('name') alias = request.form.get('alias') type = request.form.get('type') platform = request.form.get('platform') ref_id = request.form.get('ref_id', 0, type=int) # desplay order inc display_order = NewChannelService.count() + 1 NewChannelService.add(name, alias, type, platform, ref_id, display_order) return redirect(url_for('admin.list_new_channels'))
def list_activitys(): page = request.args.get('page', 1, type=int) count = request.args.get('count', 20, type=int) events = ChannelService.get_all() activitys = ActivityService.get_all((page - 1) * count, count) activity_count = ActivityService.count() pagination = Pagination(page, count, activity_count) return render_template('admin/activity/list.html', events=events, activitys=activitys, pagination=pagination)
def list_topassist(): events = ChannelService.get_all(type='football') if events: default_id = events[1]['id'] try: event_id = int(request.args.get('event_id', default_id)) except: raise InvalidArgument() scorers = TopassistService.get_all(event_id) def get_info(num, scorer): if scorer['player_id']: player = PlayerService.get_one(scorer['player_id']) scorer['player_photo'] = player['photo'] scorer['player_name'] = player['name'] team_info = TeamPlayerService.get_filter_one(scorer['player_id']) if team_info: scorer['team_id'] = team_info['team_id'] team = TeamService.get_one(team_info['team_id']) if team: scorer['team_name'] = team['name'] scorer['ranking'] = num return scorer scorers = [get_info(num + 1, scorer) for num, scorer in enumerate(scorers)] teams = EventTeamService.get_all(event_id) def get_team_info(team): team = TeamService.get_one(team['team_id']) team['name'] = team['name'] return team teams = map(get_team_info, teams) return render_template('admin/scoreboard/list_assists.html', events=events, datas=scorers, teams=teams, event_id=event_id)
def mainboard_list_slides(): platform = request.args.get('platform', 'app') channel_id = int(request.args.get('channel_id', 0)) slides = MainBoardSlideService.get_all() if channel_id == 0: slides = MainBoardSlideService.get_all(channel_id=channel_id) if channel_id: slides = MainBoardSlideService.get_all(channel_id=channel_id) channels = ChannelService.get_all(type='football') return render_template('admin/mainboard/slide/list.html', slides=slides, channel_id=channel_id, channels=channels)
def channel_entrance(): # True is all and mobile events = ChannelService.get_all(type='football') if events: default_id = events[1]['id'] else: return render_template('admin/scoreboard/cup_list.html', pages=[]) try: event_id = int(request.args.get('event_id', default_id)) except: raise InvalidArgument() pages = SubPageService.get_all(event_id=event_id) return render_template('admin/channel/channel_entrance.html', events=events, event_id=event_id, pages=pages)
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'))
def layout_side(): channels = ChannelService.get_all() return render_template('admin/side.html', channels=channels)