Commit c2bf132d authored by Hamza Dely's avatar Hamza Dely

[consos] Correction de typos

parent b0776e05
......@@ -63,13 +63,10 @@ class TransactionSerializer(serializers.ModelSerializer):
class Meta:
model = Transaction
fields = [
'id', 'date', 'action', 'moyen', 'quantite', 'montant',
'categorie', 'description', 'valide', 'emetteur', 'destinataire',
'id', 'date', 'action', 'moyen', 'quantite',
'montant', 'categorie', 'description', 'valide', 'emetteur',
'destinataire', 'emetteurs', 'destinataires', 'bouton',
]
read_only_fields = ['id']
read_only_fields = ['date', 'emetteur', 'destinataire']
def create(self, validated_data):
......@@ -83,7 +80,7 @@ class TransactionSerializer(serializers.ModelSerializer):
destinataires = []
if params['action'] == Transaction.VENTE:
bouton = Bouton.objects.get(id=validated_data.get('bouton'))
bouton = validated_data.get('bouton')
params['moyen'] = Transaction.NOTE
params['montant'] = bouton.montant
params['categorie'] = bouton.categorie
......
......@@ -673,7 +673,7 @@ class TransactionViewSet(viewsets.GenericViewSet):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
if (any(emetteur != request.user.pk for emetteur in serializer.emetteurs)
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()
......
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