src/pyams_content/shared/common/__init__.py
changeset 305 b5967aacf4c1
parent 277 9649f8ce3b1c
child 401 c004b91ebcbd
--- a/src/pyams_content/shared/common/__init__.py	Fri Dec 08 10:41:32 2017 +0100
+++ b/src/pyams_content/shared/common/__init__.py	Fri Dec 08 10:42:11 2017 +0100
@@ -18,7 +18,7 @@
 # import interfaces
 from hypatia.interfaces import ICatalog
 from pyams_content.interfaces import IBaseContentInfo
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
+from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE
 from pyams_content.features.review.interfaces import IReviewComments
 from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, \
     IBaseSharedTool, ISharedSite
@@ -245,6 +245,14 @@
                     else:
                         output.append(missing_lang_value.format(field=translate(IWfSharedContent[attr].title),
                                                                 lang=lang))
+                else:
+                    length = len(value)
+                    if (attr == 'title') and (length < 40 or length > 66):
+                        output.append(translate(ERROR_VALUE).format(
+                            field=translate(IWfSharedContent[attr].title),
+                            message=translate(_("title length should be between 40 and 66 characters ({length} "
+                                                "actually)")).format(length=length)
+                        ))
         if not self.context.keywords:
             output.append(missing_value.format(field=translate(IWfSharedContent['keywords'].title)))
         return output