feat: rotate pictures with API+AlpineJS

This commit is contained in:
imperosol
2026-05-01 18:54:13 +02:00
parent 441a016025
commit 399a3813f0
6 changed files with 144 additions and 46 deletions
+13
View File
@@ -176,6 +176,19 @@ class PicturesController(ControllerBase):
def delete_picture(self, picture_id: int):
self.get_object_or_exception(Picture, pk=picture_id).delete()
@route.post(
"/{picture_id}/rotate/{direction}",
permissions=[IsSasAdmin],
response=PictureSchema,
url_name="rotate_picture",
)
def rotate_picture(self, picture_id: int, direction: Literal["left", "right"]):
"""Rotate the given picture and returns its edited data."""
angle = 90 if direction == "left" else 270
picture = self.get_object_or_exception(Picture, pk=picture_id)
picture.rotate(angle)
return picture
@route.patch(
"/{picture_id}/moderation",
permissions=[IsSasAdmin],