--- a/src/pyams_content/component/theme/__init__.py Tue Jul 10 16:59:55 2018 +0200
+++ b/src/pyams_content/component/theme/__init__.py Wed Jul 11 10:18:10 2018 +0200
@@ -18,7 +18,8 @@
# import interfaces
from pyams_content.component.theme.interfaces import IThemesManagerTarget, IThemesManager, THEMES_MANAGER_KEY, \
IThemesTarget, IThemesInfo, THEMES_INFO_KEY, ITagsManager, ITagsManagerTarget, TAGS_MANAGER_KEY, ITagsInfo, \
- ITagsTarget, TAGS_INFO_KEY
+ ITagsTarget, TAGS_INFO_KEY, ICollectionsManager, ICollectionsManagerTarget, COLLECTIONS_MANAGER_KEY, \
+ ICollectionsInfo, ICollectionsTarget, COLLECTIONS_INFO_KEY
from pyams_content.features.checker.interfaces import IContentChecker, ERROR_VALUE
# import packages
@@ -116,7 +117,7 @@
"""Themes info content checker"""
label = _("Themes")
- weight = 200
+ weight = 210
def inner_check(self, request):
output = []
@@ -126,3 +127,51 @@
output.append(translate(ERROR_VALUE).format(field=translate(IThemesInfo['themes'].title),
message=translate(_("no defined theme"))))
return output
+
+
+#
+# Collections management
+#
+
+@implementer(ICollectionsManager)
+class CollectionsManager(Persistent, Contained):
+ """Collections manager persistent class"""
+
+ thesaurus_name = FieldProperty(ICollectionsManager['thesaurus_name'])
+ extract_name = FieldProperty(ICollectionsManager['extract_name'])
+
+
+@adapter_config(context=ICollectionsManagerTarget, provides=ICollectionsManager)
+def collections_manager_factory(target):
+ """Collections manager factory"""
+ return get_annotation_adapter(target, COLLECTIONS_MANAGER_KEY, CollectionsManager, name='++collections-manager++')
+
+
+@implementer(ICollectionsInfo)
+class CollectionsInfo(Persistent, Contained):
+ """Collections info persistent class"""
+
+ collections = FieldProperty(ICollectionsInfo['collections'])
+
+
+@adapter_config(context=ICollectionsTarget, provides=ICollectionsInfo)
+def collections_info_factory(target):
+ """Collections info factory"""
+ return get_annotation_adapter(target, COLLECTIONS_INFO_KEY, CollectionsInfo, name='++collections++')
+
+
+@adapter_config(name='collections', context=ICollectionsTarget, provides=IContentChecker)
+class CollectionsContentChecker(BaseContentChecker):
+ """Collections info content checker"""
+
+ label = _("Collections")
+ weight = 215
+
+ def inner_check(self, request):
+ output = []
+ translate = request.localizer.translate
+ collections = ICollectionsInfo(self.context)
+ if not collections.collections:
+ output.append(translate(ERROR_VALUE).format(field=translate(ICollectionsInfo['collections'].title),
+ message=translate(_("no defined collection"))))
+ return output