]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
models: Ensure UserProfile.user is configured
authorStephen Finucane <stephen@that.guru>
Sat, 3 Nov 2018 21:47:51 +0000 (21:47 +0000)
committerStephen Finucane <stephen@that.guru>
Sat, 22 Dec 2018 22:35:44 +0000 (22:35 +0000)
Django Admin seems to be doing something funky with how it's handling
the creation of a User's corresponding UserProfile instance when
modelled as an inline field. Re-setting the UserProfile.user attribute
seems to resolve the issue, so do just that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #110
(cherry picked from commit b1c2e80187008aff472c6509c67f44583cd3334c)

patchwork/models.py
releasenotes/notes/issue-110-a5bb3184bf831280.yaml [new file with mode: 0644]

index 6268f5b72e3c362315eec5e41fa7e9b509a0c218..1a2de60a5dba1fd8299ec25d97dd3f69e939bb9b 100644 (file)
@@ -212,6 +212,7 @@ class UserProfile(models.Model):
 def _user_saved_callback(sender, created, instance, **kwargs):
     try:
         profile = instance.profile
+        profile.user = instance
     except UserProfile.DoesNotExist:
         profile = UserProfile(user=instance)
     profile.save()
diff --git a/releasenotes/notes/issue-110-a5bb3184bf831280.yaml b/releasenotes/notes/issue-110-a5bb3184bf831280.yaml
new file mode 100644 (file)
index 0000000..16a0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Assigning maintained projects when creating a new user in the admin page
+    was causing an error. This is now resolved.