summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Demonte <nicolas@affinitic.be>2019-02-12 09:17:04 (GMT)
committerNicolas Demonte <nicolas@affinitic.be>2019-02-12 09:32:01 (GMT)
commit117ad34b22d9e63b152ba8df4d4f5c1eeeab9352 (patch)
tree372226d8aae6ac9706cf3f5586f33e12f55ead05
parent725827414dc446f0a3ae8367646e642e71e8d2fa (diff)
downloadpfwbged.policy-117ad34b22d9e63b152ba8df4d4f5c1eeeab9352.zip
pfwbged.policy-117ad34b22d9e63b152ba8df4d4f5c1eeeab9352.tar.gz
pfwbged.policy-117ad34b22d9e63b152ba8df4d4f5c1eeeab9352.tar.bz2
Fix edge case for validation reversal #22008
-rw-r--r--src/pfwbged/policy/subscribers/document.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pfwbged/policy/subscribers/document.py b/src/pfwbged/policy/subscribers/document.py
index 6f47610..a14edc3 100644
--- a/src/pfwbged/policy/subscribers/document.py
+++ b/src/pfwbged/policy/subscribers/document.py
@@ -103,13 +103,15 @@ def change_validation_state(context, event):
elif event.transition.id == 'cancel-validation':
for ref in catalog.findRelations(query):
validation = ref.from_object
- api.content.transition(validation, 'cancel-validation')
- validation.reindexObject(idxs=['review_state'])
+ if api.content.get_state(validation) == 'validated':
+ api.content.transition(validation, 'cancel-validation')
+ validation.reindexObject(idxs=['review_state'])
elif event.transition.id == 'cancel-refusal':
for ref in catalog.findRelations(query):
validation = ref.from_object
- api.content.transition(validation, 'cancel-refusal')
- validation.reindexObject(idxs=['review_state'])
+ if api.content.get_state(validation) == 'refused':
+ api.content.transition(validation, 'cancel-refusal')
+ validation.reindexObject(idxs=['review_state'])
@grok.subscribe(IDmsFile, IObjectWillBeRemovedEvent)