--- a/src/pyams_content/shared/imagemap/paragraph.py Fri Feb 09 12:34:19 2018 +0100
+++ b/src/pyams_content/shared/imagemap/paragraph.py Fri Feb 09 15:38:54 2018 +0100
@@ -20,7 +20,7 @@
from pyams_content.features.checker.interfaces import IContentChecker, ERROR_VALUE, MISSING_VALUE, MISSING_LANG_VALUE
from pyams_content.shared.imagemap.interfaces import IImageMapParagraph
from pyams_i18n.interfaces import II18nManager, INegotiator, II18n
-from pyams_workflow.interfaces import IWorkflow
+from pyams_workflow.interfaces import IWorkflow, IWorkflowState
# import packages
from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
@@ -77,10 +77,22 @@
output.append(translate(MISSING_VALUE).format(field=field_title))
else:
output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
- target = self.context.get_target()
- if target is not None:
- workflow = IWorkflow(target, None)
- if workflow is not None:
- output.append(translate(ERROR_VALUE).format(field=translate(IImageMapParagraph['reference'].title),
- message=translate(_("target is not published"))))
+ field_title = translate(IImageMapParagraph['reference'].title)
+ if not self.context.reference:
+ output.append(translate(ERROR_VALUE).format(field=field_title,
+ message=translate(_("internal reference is not defined"))))
+ else:
+ target = self.context.get_target()
+ if target is None:
+ output.append(translate(ERROR_VALUE).format(field=field_title,
+ message=translate(_("internal reference target can't be "
+ "found"))))
+ else:
+ workflow = IWorkflow(target, None)
+ if workflow is not None:
+ workflow_state = IWorkflowState(target)
+ if workflow_state.state not in workflow.published_states:
+ output.append(translate(ERROR_VALUE).format(field=field_title,
+ message=translate(_("internal reference target "
+ "is not published"))))
return output