mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Création d'un profile selector [#37,#38]
This commit is contained in:
@ -14,7 +14,7 @@ class ProfileSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Profile
|
||||
fields = ['id', 'password', 'email', 'code', 'datePeremption', 'username', 'roles']
|
||||
fields = ['id', 'password', 'email', 'code', 'datePeremption', 'username', 'roles', 'roleIndexLoginDefault']
|
||||
extra_kwargs = {'password': {'write_only': True}}
|
||||
|
||||
def get_roles(self, obj):
|
||||
@ -53,10 +53,10 @@ class ProfileSerializer(serializers.ModelSerializer):
|
||||
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.full_clean()
|
||||
instance.save()
|
||||
return instance
|
||||
@ -114,7 +114,7 @@ class ProfileRoleSerializer(serializers.ModelSerializer):
|
||||
if obj.profile:
|
||||
return obj.profile.email
|
||||
return None
|
||||
|
||||
|
||||
def get_associated_person(self, obj):
|
||||
if obj.role_type == ProfileRole.RoleType.PROFIL_PARENT:
|
||||
guardian = Guardian.objects.filter(profile_role=obj).first()
|
||||
|
||||
Reference in New Issue
Block a user