cleanup
parent
3094205362
commit
aec88afc0d
@ -1,30 +0,0 @@
|
||||
from flask import render_template, Blueprint, flash
|
||||
from flask import request, redirect, url_for, session
|
||||
from suchwow.models import Post, Comment, Profile
|
||||
from suchwow.utils.decorators import login_required
|
||||
|
||||
|
||||
bp = Blueprint("comment", "comment")
|
||||
|
||||
@bp.route("/comment/create/post/<post_id>", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def create(post_id):
|
||||
if not Post.filter(id=post_id):
|
||||
flash("WTF, that post doesn't exist. Stop it, hackerman.", "is-danger")
|
||||
return redirect(url_for("main.index"))
|
||||
|
||||
if request.method == "POST":
|
||||
comment_text = request.form.get("comment")
|
||||
if len(comment_text) > 300:
|
||||
flash("WTF, too many characters to post, asshole.", "is-danger")
|
||||
return redirect(request.url)
|
||||
commenter = Profile.get(username=session["auth"]["preferred_username"])
|
||||
post = Post.get(id=post_id)
|
||||
c = Comment(
|
||||
comment=comment_text,
|
||||
commenter=commenter,
|
||||
post=post,
|
||||
)
|
||||
c.save()
|
||||
return redirect(url_for("post.read", id=post_id))
|
||||
return render_template("comment/create.html")
|
Loading…
Reference in New Issue