Beispiel #1
0
def new():
    u = current_user()
    if u is not None and u.role == 1:
        boards = Board.all()
    else:
        boards = Board.all_not_hide()
    return render_template("topic/new.html", boards=boards, u=u)
Beispiel #2
0
def search():
    u = current_user()
    if u is None:
        return redirect(url_for('index.index'))
    search_content = request.args['content']
    # 根据评论数排序
    if u is not None and u.role == 1:
        ms, pages = Topic.get_topics(sort_by_replies=True,
                                     get_pages=True,
                                     search=search_content,
                                     role=1)
        boards = Board.all()
    else:
        ms, pages = Topic.get_topics(sort_by_replies=True,
                                     get_pages=True,
                                     search=search_content)
        boards = Board.all_not_hide()
    return render_template("topic/index.html",
                           ms=ms,
                           u=u,
                           boards=boards,
                           page=1,
                           board_id=-1,
                           pages=pages)
Beispiel #3
0
def index():
    u = current_user()
    board_id = int(request.args.get('board_id', -1))
    page = int(request.args.get('page', 1))
    if u is not None and u.role == 1:
        topics, pages = Topic.get_topics(board_id,
                                         page,
                                         sort_by_replies=True,
                                         get_pages=True,
                                         role=1)
        boards = Board.all()
    else:
        topics, pages = Topic.get_topics(board_id,
                                         page,
                                         sort_by_replies=True,
                                         get_pages=True)
        boards = Board.all_not_hide()
    return render_template("topic/index.html",
                           ms=topics,
                           u=u,
                           boards=boards,
                           page=page,
                           board_id=board_id,
                           pages=pages)