# HG changeset patch # User Thierry Florac # Date 1512726131 -3600 # Node ID b5967aacf4c189e691d79692232b1c11d75d2d64 # Parent 14b2ae98f78c7c238e06efeaba651beab787a49b Added content check on title length diff -r 14b2ae98f78c -r b5967aacf4c1 src/pyams_content/shared/common/__init__.py --- 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