mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-03 03:46:08 +00:00
feat: rotate pictures with API+AlpineJS
This commit is contained in:
+13
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user