mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Gestion des profils des enseignants / Visualisation d'une classe [#4]
This commit is contained in:
@ -26,3 +26,26 @@ class ProfilSerializer(serializers.ModelSerializer):
|
||||
ret = super().to_representation(instance)
|
||||
ret['password'] = '********'
|
||||
return ret
|
||||
|
||||
class ProfilUpdateSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Profil
|
||||
fields = ['id', 'password', 'email', 'code', 'datePeremption', 'estConnecte', 'droit', 'username', 'is_active']
|
||||
extra_kwargs = {
|
||||
'password': {'write_only': True, 'required': False}
|
||||
}
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
password = validated_data.pop('password', None)
|
||||
instance = super().update(instance, validated_data)
|
||||
|
||||
if password:
|
||||
instance.set_password(password)
|
||||
instance.save()
|
||||
|
||||
return instance
|
||||
|
||||
def to_representation(self, instance):
|
||||
ret = super().to_representation(instance)
|
||||
ret['password'] = '********'
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user