Corrected owner change handler
authorThierry Florac <thierry.florac@onf.fr>
Mon, 20 Jun 2016 17:46:00 +0200
changeset 47 de12e7f11dad
parent 46 54e9500c3a00
child 48 0d9128d5580d
Corrected owner change handler
src/pyams_content/shared/common/zmi/owner.py
--- a/src/pyams_content/shared/common/zmi/owner.py	Mon Jun 20 15:54:32 2016 +0200
+++ b/src/pyams_content/shared/common/zmi/owner.py	Mon Jun 20 17:46:00 2016 +0200
@@ -104,9 +104,14 @@
             previous_owner = next(iter(roles.owner))
             roles.owner = {new_owner}
             contributors = roles.contributors
-            if (previous_owner in contributors) and not data.get('keep_owner_as_contributor'):
-                contributors.remove(previous_owner)
+            if data.get('keep_owner_as_contributor'):
+                if previous_owner not in contributors:
+                    contributors.add(previous_owner)
+            else:
+                if previous_owner in contributors:
+                    contributors.remove(previous_owner)
             contributors.add(new_owner)
+            roles.contributors = contributors
             self.request.registry.notify(ObjectModifiedEvent(version))