From 795475fe155ca511bcf51d48365a136f4e838c63 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 19 Nov 2021 13:32:54 +0100 Subject: [PATCH] [pricelist] Delete old images --- flaschengeist/plugins/pricelist/pricelist_controller.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flaschengeist/plugins/pricelist/pricelist_controller.py b/flaschengeist/plugins/pricelist/pricelist_controller.py index bd89518..872b412 100644 --- a/flaschengeist/plugins/pricelist/pricelist_controller.py +++ b/flaschengeist/plugins/pricelist/pricelist_controller.py @@ -525,7 +525,7 @@ def delete_extra_ingredient(identifier): def save_drink_picture(identifier, file): - drink = get_drink(identifier) + drink = delete_drink_picture(identifier) drink.image_ = image_controller.upload_image(file) db.session.commit() return drink @@ -533,6 +533,8 @@ def save_drink_picture(identifier, file): def delete_drink_picture(identifier): drink = get_drink(identifier) - drink.image = None + if drink.image_: + db.session.delete(drink.image_) + drink.image_ = None db.session.commit() return drink