]> 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 17:56:11 +0000 (17:56 +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
patchwork/models.py
releasenotes/notes/issue-110-a5bb3184bf831280.yaml [new file with mode: 0644]

index a483dc642ffb8ba1baf92ae3a11d0559907c35fb..a7eee4dbad9a53afd9ce8882ff985260d2fc9fe5 100644 (file)
@@ -194,6 +194,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.