mirror of
https://github.com/gmbrax/Pilgrim.git
synced 2026-11-10 04:50:18 +00:00
Add the feature to delete all the photos from a travel diary and also remove all the references of photos inside the entry
This commit is contained in:
parent
c5edb835b6
commit
62e084efb3
@@ -141,7 +141,7 @@ class PhotoService:
|
||||
return original
|
||||
return None
|
||||
|
||||
def delete(self, photo_src: Photo) -> Photo | None:
|
||||
def delete(self, photo_src: Photo, commit=True) -> Photo | None:
|
||||
excluded = self.read_by_id(photo_src.id)
|
||||
if excluded:
|
||||
# Store photo data before deletion
|
||||
@@ -162,7 +162,8 @@ class PhotoService:
|
||||
file_path.unlink()
|
||||
|
||||
self.session.delete(excluded)
|
||||
self.session.commit()
|
||||
if commit:
|
||||
self.session.commit()
|
||||
|
||||
return deleted_photo
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user