src/pyams_content/shared/common/__init__.py
changeset 305 b5967aacf4c1
parent 277 9649f8ce3b1c
child 401 c004b91ebcbd
equal deleted inserted replaced
304:14b2ae98f78c 305:b5967aacf4c1
    16 # import standard library
    16 # import standard library
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from hypatia.interfaces import ICatalog
    19 from hypatia.interfaces import ICatalog
    20 from pyams_content.interfaces import IBaseContentInfo
    20 from pyams_content.interfaces import IBaseContentInfo
    21 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    21 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE
    22 from pyams_content.features.review.interfaces import IReviewComments
    22 from pyams_content.features.review.interfaces import IReviewComments
    23 from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, \
    23 from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, \
    24     IBaseSharedTool, ISharedSite
    24     IBaseSharedTool, ISharedSite
    25 from pyams_i18n.interfaces import II18nManager, II18n
    25 from pyams_i18n.interfaces import II18nManager, II18n
    26 from pyams_security.interfaces import IDefaultProtectionPolicy
    26 from pyams_security.interfaces import IDefaultProtectionPolicy
   243                     if len(langs) == 1:
   243                     if len(langs) == 1:
   244                         output.append(missing_value.format(field=translate(IWfSharedContent[attr].title)))
   244                         output.append(missing_value.format(field=translate(IWfSharedContent[attr].title)))
   245                     else:
   245                     else:
   246                         output.append(missing_lang_value.format(field=translate(IWfSharedContent[attr].title),
   246                         output.append(missing_lang_value.format(field=translate(IWfSharedContent[attr].title),
   247                                                                 lang=lang))
   247                                                                 lang=lang))
       
   248                 else:
       
   249                     length = len(value)
       
   250                     if (attr == 'title') and (length < 40 or length > 66):
       
   251                         output.append(translate(ERROR_VALUE).format(
       
   252                             field=translate(IWfSharedContent[attr].title),
       
   253                             message=translate(_("title length should be between 40 and 66 characters ({length} "
       
   254                                                 "actually)")).format(length=length)
       
   255                         ))
   248         if not self.context.keywords:
   256         if not self.context.keywords:
   249             output.append(missing_value.format(field=translate(IWfSharedContent['keywords'].title)))
   257             output.append(missing_value.format(field=translate(IWfSharedContent['keywords'].title)))
   250         return output
   258         return output
   251 
   259 
   252 
   260