示例#1
0
def new():
    board_id = int(request.args.get('board_id', -1))
    bs = Board.all()
    # return render_template("topic/new.html", bs=bs, bid=board_id)
    token = new_csrf_token()
    return render_template("topic/new.html",
                           bs=bs,
                           token=token,
                           bid=board_id,
                           hots=Topic.hots(),
                           user=current_user())
示例#2
0
def detail(id):
    m = Topic.get(id)
    # 当存在时返回页面,不存在返回主页
    if m:
        # 传递 topic 的所有 reply 到 页面中
        return render_template("topic/detail.html",
                               topic=m,
                               user=current_user(),
                               hots=Topic.hots())
    else:
        return redirect(url_for('.index'))
示例#3
0
def index():
    u = current_user()

    sent_mail = Mail.all(sender_id=u.id)
    received_mail = Mail.all(receiver_id=u.id)

    t = render_template('mail/index.html',
                        send=sent_mail,
                        received=received_mail,
                        hots=Topic.hots(),
                        user=current_user())
    return t
示例#4
0
def user_profile(username):
    # u = User.find_by(username=username)
    u = User.one(username=username)
    if u is None:
        abort(404)
    else:
        # topics = Topic.find_all(user_id=u.id)
        topics = Topic.all(user_id=u.id)
        reply_topic = Topic.user_participated(u)
        return render_template('user.html',
                               user=u,
                               reply_topic=reply_topic,
                               topics=topics,
                               hots=Topic.hots(),
                               u=current_user())
示例#5
0
def index():
    board_id = int(request.args.get('board_id', -1))
    hots = Topic.hots()
    if board_id == -1:
        ms = Topic.all(deleted=0)
    else:
        # ms = Topic.find_all(board_id=board_id)
        ms = Topic.all(board_id=board_id, deleted=0)

    token = new_csrf_token()
    bs = Board.all()
    user = current_user()
    return render_template("topic/index.html",
                           ms=ms,
                           token=token,
                           bs=bs,
                           bid=board_id,
                           user=user,
                           hots=hots)