Commit 4ec3d61f authored by Hamza Dely's avatar Hamza Dely

[consos/views] On renvoie les identifiants des nouveaux objets lors d'un appel à l'API

parent 788da056
......@@ -396,8 +396,8 @@ class NoteViewSet(viewsets.GenericViewSet):
"""
serializer = self.get_serializer(data=request.data, fields=['adherent'])
serializer.is_valid(raise_exception=True)
serializer.save()
return Response({}, status=status.HTTP_201_CREATED)
instance = serializer.save()
return Response({"id" : instance.id}, status=status.HTTP_201_CREATED)
@detail_route(methods=['patch'])
@requires("consos.note_soft_lock")
......@@ -537,8 +537,8 @@ class BoutonViewSet(viewsets.GenericViewSet):
return Response({"detail" : "Vous n'avez pas le droit de lier un bouton à une autre note que la vôtre"}, status=status.HTTP_403_FORBIDDEN)
if note.type not in [note.proprietaire.CLUB, note.proprietaire.SECTION] and not request.user.has_perm("consos.bouton_ajouter", Acl.TOTAL):
return Response({"detail" : "Vous n'avez pas le droit de lier un bouton à autre chose qu'un club ou une section"}, status=status.HTTP_403_FORBIDDEN)
serializer.save()
return Response({}, status=status.HTTP_201_CREATED)
instance = serializer.save()
return Response({"id" : instance.id}, status=status.HTTP_201_CREATED)
@requires("consos.bouton_modifer")
def partial_update(self, request, pk=None):
......@@ -618,8 +618,8 @@ class TransactionViewSet(viewsets.GenericViewSet):
if (any(emetteur != request.user for emetteur in serializer.validated_data.get('emetteurs', []))
and not request.user.has_perm("consos.transaction_effectuer", Acl.TOTAL)):
return Response({"detail" : "Vous ne pouvez faire que des transactions depuis vôtre note"}, status=status.HTTP_403_FORBIDDEN)
serializer.save()
return Response({}, status=status.HTTP_201_CREATED)
instances = serializer.save()
return Response({"id" : [instance.id for instance in instances]}, status=status.HTTP_201_CREATED)
@detail_route(methods=['patch'])
@requires("consos.transaction_devalider")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment