|
|
|
@ -92,6 +92,24 @@ def create():
|
|
|
|
|
return redirect(url_for("post.read", id=post.id))
|
|
|
|
|
return render_template("post/create.html")
|
|
|
|
|
|
|
|
|
|
@bp.route("/post/<id>/delete")
|
|
|
|
|
@login_required
|
|
|
|
|
def delete(id):
|
|
|
|
|
filtered = Post.filter(id=id)
|
|
|
|
|
user = session["auth"]["preferred_username"]
|
|
|
|
|
if filtered:
|
|
|
|
|
post = filtered.first()
|
|
|
|
|
if user == post.submitter:
|
|
|
|
|
post.delete_instance()
|
|
|
|
|
flash("Deleted that shit, brah!")
|
|
|
|
|
return redirect(url_for("index"))
|
|
|
|
|
else:
|
|
|
|
|
flash("You can't delete a meme you don't own, brah")
|
|
|
|
|
return redirect(url_for("post.read", id=post.id))
|
|
|
|
|
else:
|
|
|
|
|
flash("No meme there, brah")
|
|
|
|
|
return redirect(url_for("index"))
|
|
|
|
|
|
|
|
|
|
@bp.route("/uploads/<path:filename>")
|
|
|
|
|
def uploaded_file(filename):
|
|
|
|
|
file_path = path.join(current_app.config["DATA_FOLDER"], "uploads")
|
|
|
|
|