mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
add deletes
This commit is contained in:
parent
783b482a0a
commit
f655943898
2 changed files with 24 additions and 0 deletions
|
@ -92,6 +92,24 @@ def create():
|
||||||
return redirect(url_for("post.read", id=post.id))
|
return redirect(url_for("post.read", id=post.id))
|
||||||
return render_template("post/create.html")
|
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>")
|
@bp.route("/uploads/<path:filename>")
|
||||||
def uploaded_file(filename):
|
def uploaded_file(filename):
|
||||||
file_path = path.join(current_app.config["DATA_FOLDER"], "uploads")
|
file_path = path.join(current_app.config["DATA_FOLDER"], "uploads")
|
||||||
|
|
|
@ -58,6 +58,12 @@
|
||||||
|
|
||||||
<a href="{{ url_for('comment.create', post_id=post.id) }}"><button class="btn btn-warning">Leave a Comment</button></a>
|
<a href="{{ url_for('comment.create', post_id=post.id) }}"><button class="btn btn-warning">Leave a Comment</button></a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% if session.auth.preferred_username == post.submitter %}
|
||||||
|
<hr><a href="{{ url_for('post.delete', id=post.id) }}"><button class="btn btn-danger">Delete Post</button></a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue