--- a/src/pyams_content/shared/common/__init__.py Fri Nov 10 12:05:25 2017 +0100
+++ b/src/pyams_content/shared/common/__init__.py Fri Nov 10 12:05:58 2017 +0100
@@ -18,8 +18,10 @@
# import interfaces
from hypatia.interfaces import ICatalog
from pyams_content.interfaces import IBaseContentInfo
-from pyams_content.interfaces.review import IReviewComments
+from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
+from pyams_content.features.review.interfaces import IReviewComments
from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, ISharedTool
+from pyams_i18n.interfaces import II18nManager, II18n
from pyams_security.interfaces import IDefaultProtectionPolicy
from pyams_sequence.interfaces import ISequentialIdTarget, ISequentialIdInfo
from pyams_utils.interfaces import VIEW_PERMISSION
@@ -31,6 +33,7 @@
# import packages
from persistent import Persistent
+from pyams_content.features.checker import BaseContentChecker
from pyams_i18n.content import I18nManagerMixin
from pyams_security.property import RolePrincipalsFieldProperty
from pyams_security.security import ProtectedObject
@@ -174,7 +177,9 @@
# reset modifiers
content.modifiers = set()
# clear review comments
- IReviewComments(content).clear()
+ comments = IReviewComments(content, None)
+ if comments is not None:
+ comments.clear()
@adapter_config(context=IWfSharedContent, provides=ISequentialIdInfo)
@@ -204,6 +209,33 @@
return query_utility(IWorkflow, name=parent.shared_content_workflow)
+@adapter_config(name='properties', context=IWfSharedContent, provides=IContentChecker)
+class WfSharedContentChecker(BaseContentChecker):
+ """Default shared content checker"""
+
+ label = _("Properties")
+
+ def inner_check(self, request):
+ output = []
+ translate = request.localizer.translate
+ missing_value = translate(MISSING_VALUE)
+ missing_lang_value = translate(MISSING_LANG_VALUE)
+ i18n = II18n(self.context)
+ langs = II18nManager(self.context).get_languages()
+ for attr in ('title', 'short_name', 'description'):
+ for lang in langs:
+ value = i18n.get_attribute(attr, lang, request)
+ if not value:
+ if len(langs) == 1:
+ output.append(missing_value.format(field=translate(IWfSharedContent[attr].title)))
+ else:
+ output.append(missing_lang_value.format(field=translate(IWfSharedContent[attr].title),
+ lang=lang))
+ if not self.context.keywords:
+ output.append(missing_value.format(field=translate(IWfSharedContent['keywords'].title)))
+ return output
+
+
#
# Main shared content class and adapters
#