|
|
|
@ -506,6 +506,17 @@ class AdminBookReferenceImageViewSet(ModelViewSet): |
|
|
|
queryset = queryset.filter(book_reference_id=book_reference_id) |
|
|
|
return queryset.order_by("order", "id") |
|
|
|
|
|
|
|
@action(detail=False, methods=["post"]) |
|
|
|
def reorder(self, request): |
|
|
|
image_ids = request.data.get("image_ids", []) or request.data.get("ids", []) |
|
|
|
if not image_ids: |
|
|
|
return Response({"error": "image_ids list is required"}, status=400) |
|
|
|
|
|
|
|
for index, img_id in enumerate(image_ids, start=1): |
|
|
|
BookReferenceImage.objects.filter(id=img_id).update(order=index) |
|
|
|
|
|
|
|
return Response({"status": "success"}) |
|
|
|
|
|
|
|
|
|
|
|
class AdminBookReferenceDocumentViewSet(ModelViewSet): |
|
|
|
serializer_class = AdminBookReferenceDocumentSerializer |
|
|
|
|