Commit 087daf0d authored by Hamza Dely's avatar Hamza Dely
Browse files

[comptes/views] s/AdherentSerializer/get_serializer/

parent 7da8c942
......@@ -663,21 +663,21 @@ class AdherentViewSet(viewsets.GenericViewSet):
if request.user.has_perm("comptes.adherent_detail", Acl.TOTAL):
# Accès à toutes les données sans limitation
serializer = AdherentSerializer(target_user)
serializer = self.get_serializer(target_user)
elif request.user.id == target_user.id:
# Accès à toutes les données, sauf aux remarques
serializer = AdherentSerializer(target_user)
serializer = self.get_serializer(target_user)
del serializer.fields['remarque']
elif request.user.has_perm("comptes.adherent_detail", Acl.ETENDU):
# Accès aux informations personnelles de l'adhérent
serializer = AdherentSerializer(target_user)
serializer = self.get_serializer(target_user)
allowed_fields = Adherent.CHAMPS_VISIBLES[Acl.ETENDU]
for field in dict(serializer.fields).keys():
if field not in allowed_fields:
del serializer.fields[field]
else:
# Accès aux informations basiques sur l'adhérent
serializer = AdherentSerializer(target_user)
serializer = self.get_serializer(target_user)
allowed_fields = Adherent.CHAMPS_VISIBLES[Acl.BASIQUE]
for field in dict(serializer.fields).keys():
if field not in allowed_fields:
......@@ -701,23 +701,23 @@ class AdherentViewSet(viewsets.GenericViewSet):
if request.user.has_perm("comptes.adherent_modifier", Acl.TOTAL):
# Toutes les données peuvent être modifiées
serializer = AdherentSerializer(target_user, data=request.data, partial=True)
serializer = self.get_serializer(target_user, data=request.data, partial=True)
elif request.user.id == target_user.id:
# Toutes les données sont modifiables, sauf les remarques et
# l'indication du statut de membre actif
serializer = AdherentSerializer(target_user, data=request.data, partial=True)
serializer = self.get_serializer(target_user, data=request.data, partial=True)
del serializer.fields['remarque']
del serializer.fields['is_staff']
elif request.user.has_perm("comptes.adherent_modifier", Acl.ETENDU):
# Les informations personnelles de l'adhérent sont modifiables
serializer = AdherentSerializer(target_user, data=request.data, partial=True)
serializer = self.get_serializer(target_user, data=request.data, partial=True)
allowed_fields = Adherent.CHAMPS_MODIFIABLES[Acl.ETENDU]
for field in dict(serializer.fields).keys():
if field not in allowed_fields:
del serializer.fields[field]
else:
# Seules les données basiques sont modifiables
serializer = AdherentSerializer(target_user, data=request.data, partial=True)
serializer = self.get_serializer(target_user, data=request.data, partial=True)
allowed_fields = Adherent.CHAMPS_MODIFIABLES[Acl.BASIQUE]
for field in dict(serializer.fields).keys():
if field not in allowed_fields:
......
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