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:
Gustavo Henrique Santos Souza de Miranda
2025-07-24 01:54:24 -03:00
parent c5edb835b6
commit 62e084efb3
4 changed files with 59 additions and 3 deletions
+3 -2
View File
@@ -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