コード例 #1
0
def list_resources():

    fresh = request.args.get('fresh', 0, type=int)

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)
    keyword = request.form.get('keyword')

    def get_resource_info(item):
        data = eval(item['data'])
        if 'cid' in data.keys():
            item['cid'] = data['cid']
        item['image'] = add_image_domain(data['image'])
        return item

    if keyword is not None:
        resources = PendingVideoService.search_by_name(keyword)
        resources = map(get_resource_info, resources)
        return render_template('admin/media/list.html',
                               fresh=fresh,
                               resources=resources)

    resources = PendingVideoService.get_all(fresh, (page - 1) * count, count)
    resources_count = PendingVideoService.count(fresh)
    pagination = Pagination(page, count, resources_count)

    resources = map(get_resource_info, resources)

    return render_template('admin/media/list.html',
                           fresh=fresh,
                           pagination=pagination,
                           resources=resources)
コード例 #2
0
def list_event_news():

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    try:
        event_id = int(request.args.get('event_id'))
        type = request.args.get('type')
    except:
        raise InvalidArgument()

    if request.method == 'POST':
        search_id = request.form.get('search')
        return redirect(
            url_for('admin.list_event_news', event_id=search_id, type=type))

    news = EventNewsService.get_all(event_id, type, (page - 1) * count, count)

    if event_id and type:
        news_count = EventNewsService.count(event_id, type=type)
    elif event_id:
        news_count = EventNewsService.count(event_id)
    elif type:
        news_count = EventNewsService.count(type=type)
    else:
        news_count = EventNewsService.count()

    pagination = Pagination(page, count, news_count)

    return render_template('admin/event/news_list.html',
                           news=news,
                           pagination=pagination,
                           current_id=event_id,
                           current_type=type,
                           url=request.url)
コード例 #3
0
def list_olympics_news():

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    try:
        type = request.args.get('type', 'all')
    except:
        raise InvalidArgument()

    news = OGNewsService.get_all(type, (page - 1) * count, count)

    if type == 'all':
        news_count = OGNewsService.count()
    else:
        news_count = OGNewsService.count(type=type)

    pagination = Pagination(page, count, news_count)

    def add_info_sync(news):
        value = EventNewsService.search_by_title(news['title'])
        news['sync'] = bool(value)
        return news

    news = map(add_info_sync, news)

    return render_template(
        'admin/olympics/news/news_list.html',
        news=news,
        pagination=pagination,
        type=type)
コード例 #4
0
def olympics_gallery_list():
    """图集管理列表"""

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)
    gallerys = OlympicsGalleryService.get_all((page - 1) * count, count)
    videos_count = OlympicsGalleryService.count()
    pagination = Pagination(page, count, videos_count)

    return render_template('admin/olympics/gallery/list.html',
                           pagination=pagination,
                           gallerys=gallerys)
コード例 #5
0
def list_players():

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    players = PlayerService.get_show_all((page - 1) * count, count)
    player_count = PlayerService.count()
    pagination = Pagination(page, count, player_count)

    return render_template('admin/player/list.html',
                           pagination=pagination,
                           players=players)
コード例 #6
0
def olympics_champion_list():
    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)
    champions = OlympicsChampionService.get_all((page - 1) * count, count)
    videos_count = OlympicsChampionService.count()
    pagination = Pagination(page, count, videos_count)

    return render_template(
        'admin/olympics/champion/list.html',
        pagination=pagination,
        champions=champions,
    )
コード例 #7
0
def list_sections():

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    sections = SectionService.get_all((page - 1) * count, count)

    sections_count = SectionService.count()

    pagination = Pagination(page, count, sections_count)

    return render_template('admin/section/list.html',
                           sections=sections,
                           pagination=pagination)
コード例 #8
0
def list_programs():

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    programs = ProgramService.get_all((page - 1) * count, count)

    programs_count = ProgramService.count()

    pagination = Pagination(page, count, programs_count)

    return render_template('admin/program/list.html',
                           programs=programs,
                           pagination=pagination)
コード例 #9
0
def list_section_posts(section_id):

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    posts = SectionPostService.get_all(section_id, (page - 1) * count, count)

    posts_count = SectionPostService.count(section_id)

    pagination = Pagination(page, count, posts_count)

    return render_template('admin/section/list_posts.html',
                           posts=posts,
                           section_id=section_id,
                           pagination=pagination)
コード例 #10
0
def list_program_posts(program_id):

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    posts = ProgramPostService.get_all(program_id, (page - 1) * count, count)

    programs_count = ProgramPostService.count(program_id)

    pagination = Pagination(page, count, programs_count)

    return render_template('admin/program/list_posts.html',
                           posts=posts,
                           program_id=program_id,
                           pagination=pagination)
コード例 #11
0
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)
コード例 #12
0
def list_collections():

    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)

    type = request.args.get('type', 'all')
    programs = CollectionService.get_all(type, (page - 1) * count, count)

    programs_count = CollectionService.count()

    pagination = Pagination(page, count, programs_count)

    return render_template(
        'admin/olympics/collection/list.html',
        programs=programs,
        type=type,
        pagination=pagination)
コード例 #13
0
def list_olympics_videos():
    page = request.args.get('page', 1, type=int)
    count = request.args.get('count', 20, type=int)
    keyword = request.form.get('keyword')

    if keyword is not None:
        videos = OGVideoService.search_by_name(keyword)
        return render_template(
            'admin/olympics/video/videos_list.html',
            videos=videos)

    type = request.args.get('type', 'all')
    videos = OGVideoService.get_all(type, (page - 1) * count, count)
    videos_count = OGVideoService.count(type=type)
    pagination = Pagination(page, count, videos_count)

    return render_template(
        'admin/olympics/video/videos_list.html',
        videos=videos,
        pagination=pagination,
        current_type=type)