Exemplo n.º 1
0
def add(topic_id):
	u = current_user()
	if not u:
		return redirect(url_for("auth.login"))
	Reply.new_and_save(request.form)
	t = Topic.find_by_id(topic_id)
	update_comments(t)
	return redirect(url_for("topic.detail", topic_id=topic_id))
Exemplo n.º 2
0
def add():
    u = current_user()
    if not u:
        return redirect(url_for("topic.index"))
    if request.method == "GET":
        return render_template("board/add_board.html")
    else:
        Board.new_and_save(request.form)
    return redirect(url_for("topic.index"))
Exemplo n.º 3
0
def add():
    u = current_user()
    if not u:
        return redirect(url_for("auth.login"))
    if request.method == "GET":
        boards = Board.all()
        return render_template("topic/add.html", user_id=u.id, boards=boards)
    Topic.new_and_save(request.form)
    return redirect(url_for(".index"))
Exemplo n.º 4
0
def detail(topic_id):
    t = Topic.find_by_id(topic_id)
    u = current_user()
    rs = Reply.find_by(topic_id=topic_id)
    update_views(t)
    rs.sort(key=lambda x: x.floor)
    floor_count = len(rs) + 1
    return render_template("topic/detail.html",
                           topic=t,
                           user=u,
                           replies=rs,
                           floor_count=floor_count)
Exemplo n.º 5
0
def index():
    board_id = request.args.get("board", None)
    if board_id:
        board_id = int(board_id)
    topics = get_topics(board_id)
    boards = Board.all()
    user = current_user()
    return render_template("topic/index.html",
                           user=user,
                           topics=topics,
                           board_id=board_id,
                           boards=boards)
Exemplo n.º 6
0
def edit():
    user = current_user()
    if not user:
        return redirect(url_for("auth.login"))
    if request.method == "GET":
        return render_template("profile/edit_profile.html", user=user)
    else:
        form = request.form
        for k, v in form.items():
            setattr(user, k, v)
        user.update()
        return redirect("/profile/{}".format(user.id))
Exemplo n.º 7
0
def profile(user_id):
    cur_user = current_user()
    view_user = User.find_by_id(user_id)
    return render_template("profile/profile.html",
                           current_user=cur_user,
                           view_user=view_user)
Exemplo n.º 8
0
def votes(reply_id):
	u = current_user()
	r = Reply.find_by_id(reply_id)
	if u.id not in r.like_users:
		update_likes(r)
	return redirect(url_for("topic.detail", topic_id=r.topic_id))