From 5586f4d32c834032e42c3c105724f1b70c8c84a7 Mon Sep 17 00:00:00 2001 From: Nicolas Demonte Date: Tue, 15 Jan 2019 17:33:51 +0100 Subject: [PATCH] Allow returning responsibility on a task and reverting linked document #22006 --- src/pfwbged/policy/menu.py | 4 ++++ .../pfwbgeddocument_workflow/definition.xml | 1 + src/pfwbged/policy/subscribers/document.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/pfwbged/policy/menu.py b/src/pfwbged/policy/menu.py index 419afbd..41255ca 100644 --- a/src/pfwbged/policy/menu.py +++ b/src/pfwbged/policy/menu.py @@ -167,6 +167,10 @@ class CustomMenu(menu.WorkflowMenu): if action['category'] != 'workflow': continue + # that action is already triggered when returning responsibility on a task + if action['id'] == 'back_to_assigning' and IDmsDocument.providedBy(context) and api.content.get_state(context) == 'processing': + continue + cssClass = 'kssIgnore' actionUrl = action['url'] if actionUrl == "": diff --git a/src/pfwbged/policy/profiles/default/workflows/pfwbgeddocument_workflow/definition.xml b/src/pfwbged/policy/profiles/default/workflows/pfwbgeddocument_workflow/definition.xml index e9d3313..4fb7e31 100644 --- a/src/pfwbged/policy/profiles/default/workflows/pfwbgeddocument_workflow/definition.xml +++ b/src/pfwbged/policy/profiles/default/workflows/pfwbgeddocument_workflow/definition.xml @@ -149,6 +149,7 @@ + Editor Manager diff --git a/src/pfwbged/policy/subscribers/document.py b/src/pfwbged/policy/subscribers/document.py index 91b0ed4..3361ae4 100644 --- a/src/pfwbged/policy/subscribers/document.py +++ b/src/pfwbged/policy/subscribers/document.py @@ -179,6 +179,16 @@ def task_in_progress(context, event): document = obj api.content.transition(obj=document, transition='directly_noaction') document.reindexObject(idxs=['review_state']) + elif event.transition and event.transition.id == 'return-responsibility': + obj = aq_parent(context) + if not IPfwbDocument.providedBy(obj): + return + # only applies to "other documents" + if not has_pfwbgeddocument_workflow(obj): + return + document = obj + api.content.transition(obj=document, transition='back_to_assigning') + document.reindexObject(idxs=['review_state']) def transition_tasks(obj, types, status, transition): @@ -271,6 +281,11 @@ def document_is_finished(context, event): def document_is_reopened(context, event): """When a document is reoponed, create a new task""" if has_pfwbgeddocument_workflow(context) and event.transition is not None and event.new_state.id == 'assigning': + + # Task responsibility has just been returned + if event.old_state.id == 'processing': + return + creator = api.user.get_current().getId() params = {'responsible': [], 'title': translate(_(u'Process document'),