From 3ca2f2ebe91c7874c9f2a2adddd4c66eeee99754 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Tue, 6 Nov 2018 17:14:47 +0100
Subject: [PATCH] Use update instead of save when creating new Profile

---
 profiles/forms.py | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/profiles/forms.py b/profiles/forms.py
index 63a46e618..ab7d53a9e 100644
--- a/profiles/forms.py
+++ b/profiles/forms.py
@@ -59,21 +59,13 @@ class ProfileForm(forms.ModelForm):
         instance_pk = self.cleaned_data['instance_pk']
         if instance_pk:
             if self.cleaned_data['instance_from_type'] == 'contributor':
-                contributor = get_object_or_404(Contributor, pk=instance_pk)
-                contributor.profile = profile
-                contributor.save()
+                Contributor.objects.filter(pk=instance_pk).update(profile=profile)
             elif self.cleaned_data['instance_from_type'] == 'unregisteredauthor':
-                unreg_auth = get_object_or_404(UnregisteredAuthor, pk=instance_pk)
-                unreg_auth.profile = profile
-                unreg_auth.save()
+                UnregisteredAuthor.objects.filter(pk=instance_pk).update(profile=profile)
             elif self.cleaned_data['instance_from_type'] == 'refereeinvitation':
-                ref_inv = get_object_or_404(RefereeInvitation, pk=instance_pk)
-                ref_inv.profile = profile
-                ref_inv.save()
+                RefereeInvitation.objects.filter(pk=instance_pk).update(profile=profile)
             elif self.cleaned_data['instance_from_type'] == 'registrationinvitation':
-                reg_inv = get_object_or_404(RegistrationInvitation, pk=instance_pk)
-                reg_inv.profile = profile
-                reg_inv.save()
+                RegistrationInvitation.objects.filter(pk=instance_pk).update(profile=profile)
         return profile
 
 
-- 
GitLab