|
7 | 7 | from opengever.tabbedview.helper import linked |
8 | 8 | from opengever.task import _ |
9 | 9 | from opengever.task import util |
| 10 | +from plone import api |
| 11 | +from StringIO import StringIO |
10 | 12 | from z3c.relationfield import RelationValue |
11 | 13 | from zope.app.intid.interfaces import IIntIds |
12 | 14 | from zope.component import getUtility |
@@ -113,6 +115,26 @@ def complete_task_and_deliver_documents( |
113 | 115 | linked(doc, doc.Title()), |
114 | 116 | _(u'label_related_items', default=u"Related Items")) |
115 | 117 |
|
| 118 | + if api.content.get_state(task) == predecessor.review_state: |
| 119 | + # If the successor task is already in the same state as the predecessor |
| 120 | + # (e.g. both are closed), we skip changing the predecessor's state. |
| 121 | + # |
| 122 | + # This situation can occur after a conflict error during the initial |
| 123 | + # commit of the local transition. The transaction manager retries the |
| 124 | + # request, but the remote task may already have been closed and committed |
| 125 | + # to the OGDS. This is usually not an issue, but it's possible that |
| 126 | + # the current user does no longer have permission to access the predecessor |
| 127 | + # task, which would lead to an Unauthorized error and the local transition |
| 128 | + # would be aborted. Means, the predecessor remains closed, but the local |
| 129 | + # successor task is still open and cannot be closed anymore. |
| 130 | + # |
| 131 | + # When the retry attempts to close the local task again, we |
| 132 | + # detect that the predecessor is already closed as well and avoid |
| 133 | + # performing the transition on the remote admin unit a second time. |
| 134 | + # |
| 135 | + # Fixes https://4teamwork.atlassian.net/browse/TI-1633 |
| 136 | + return StringIO('OK') |
| 137 | + |
116 | 138 | request_data = {'data': json.dumps(data)} |
117 | 139 | response = dispatch_request( |
118 | 140 | predecessor.admin_unit_id, |
|
0 commit comments