From 98556998d77b043db5552c8d5ed8c0ec4e25e3ae Mon Sep 17 00:00:00 2001 From: Tore Brede <Tore.Brede@uib.no> Date: Mon, 18 Oct 2021 12:15:29 +0200 Subject: [PATCH] GREG-85: Fixing prolem with updating values --- gregui/api/serializers/guest.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/gregui/api/serializers/guest.py b/gregui/api/serializers/guest.py index b472fd80..d38b30a8 100644 --- a/gregui/api/serializers/guest.py +++ b/gregui/api/serializers/guest.py @@ -38,15 +38,9 @@ class GuestRegisterSerializer(serializers.ModelSerializer): value=email, ) else: - # Only expecting one private e-mail - private_email = Identity.objects.get( - person_id=instance.id, type=Identity.IdentityType.PRIVATE_EMAIL - ) + private_email = instance.private_email private_email.value = email private_email.save() - # TODO Figure out why the following did not work - # instance.private_email.value = email - # instance.private_email.save() if not instance.private_mobile: Identity.objects.create( @@ -55,8 +49,9 @@ class GuestRegisterSerializer(serializers.ModelSerializer): value=mobile_phone, ) else: - instance.private_mobile.value = mobile_phone - instance.private_mobile.save() + private_mobile = instance.private_mobile + private_mobile.value = mobile_phone + private_mobile.save() if "fnr" in validated_data: fnr = validated_data.pop("fnr") @@ -67,8 +62,9 @@ class GuestRegisterSerializer(serializers.ModelSerializer): value=fnr, ) else: - instance.fnr.value = fnr - instance.fnr.value.save() + fnr_existing = instance.fnr + fnr_existing.value = fnr + fnr_existing.save() # TODO: we only want to allow changing the name if we don't have one # from a reliable source (Feide/KORR) -- GitLab