feat: Recipe Timeline Images (#2444)

* refactored recipe image paths/service

* added routes for updating/fetching timeline images

* make generate

* added event image upload and rendering

* switched update to patch to preserve timestamp

* added tests

* tweaked order of requests

* always reload events when opening the timeline

* re-arranged elements to make them look nicer

* delete files when timeline event is deleted
This commit is contained in:
Michael Genson
2023-08-06 12:49:30 -05:00
committed by GitHub
parent 06962cf865
commit dfe4942451
16 changed files with 355 additions and 92 deletions

View File

@@ -98,14 +98,22 @@ class HttpRepo(Generic[C, R, U]):
return item
def patch_one(self, data: U, item_id: int | str | UUID4) -> None:
self.repo.get_one(item_id)
def patch_one(self, data: U, item_id: int | str | UUID4) -> R:
item = self.repo.get_one(item_id)
if not item:
raise HTTPException(
status.HTTP_404_NOT_FOUND,
detail=ErrorResponse.respond(message="Not found."),
)
try:
self.repo.patch(item_id, data.dict(exclude_unset=True, exclude_defaults=True))
item = self.repo.patch(item_id, data.dict(exclude_unset=True, exclude_defaults=True))
except Exception as ex:
self.handle_exception(ex)
return item
def delete_one(self, item_id: int | str | UUID4) -> R | None:
item: R | None = None
try: