Ejemplo n.º 1
0
def get_news_list():
    if not current_user.is_admin and not current_user.is_coach:
        print "你没有权限访问该模块"
        return redirect(url_for('main.index'))

    news_list = list()
    sum = 0
    offset = request.form.get('offset')
    limit = request.form.get('limit')
    if current_user.is_admin:
        news_list = news_server.get_list(offset, limit, show_draft=True)
        sum = news_server.get_count(show_draft=True)
    elif current_user.is_coach:
        news_list = news_server.get_list(offset, limit, show_draft=True, coach=current_user)
        sum = news_server.get_count(show_draft=True, coach=current_user)
    return jsonify(news_list=[get_news_list_item(news) for news in news_list],
                   sum=sum, offset=int(offset), limit=len(news_list))
Ejemplo n.º 2
0
def news_list(page = 0):
    limit = config.NEWS_PER_PAGE
    offset = int(page) * limit
    news_server.get_archive()
    news = news_server.get_list(offset, limit)
    recent_news = news_server.get_recent()
    tags = news_server.get_all_tags()
    sum = news_server.get_count()
    return render_template('index/news_list.html',
                          title = u'新闻',
                          news = news, tags = tags,
                          recent_news = recent_news,
                          page = int(page),
                          sum = sum, limit = limit)
Ejemplo n.º 3
0
def news_list(page = 0):
    limit = config.NEWS_PER_PAGE
    offset = int(page) * limit
    news_server.get_archive()
    news = news_server.get_list(offset, limit)
    recent_news = news_server.get_recent()
    tags = news_server.get_all_tags()
    sum = news_server.get_count()
    return render_template('index/news_list.html',
                          title = u'新闻',
                          news = news, tags = tags,
                          recent_news = recent_news,
                          page = int(page),
                          sum = sum, limit = limit)