feat: Création d'un profile selector [#37,#38]

This commit is contained in:
Luc SORIGNET
2025-04-12 16:07:30 +02:00
parent 4c2e2f8756
commit 89b01b79db
16 changed files with 237 additions and 286 deletions

View File

@ -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()