be sure to delete post's image when deleting from route

graphs-n-shit
lza_menace 4 years ago
parent d1cde8f63e
commit aff9f89640

@ -1,4 +1,4 @@
from os import path
from os import path, remove
from flask import render_template, Blueprint, request, session, flash
from flask import send_from_directory, redirect, url_for, current_app
from werkzeug.utils import secure_filename
@ -123,6 +123,9 @@ def delete(id):
if filtered:
post = filtered.first()
if user == post.submitter or is_mod:
save_path_base = path.join(current_app.config["DATA_FOLDER"], "uploads")
save_path = path.join(save_path_base, post.image_name)
remove(save_path)
post.delete_instance()
flash("Deleted that shit, brah!")
if is_mod:

Loading…
Cancel
Save