--- a/src/pyams_content/component/paragraph/header.py Mon Aug 27 11:32:07 2018 +0200
+++ b/src/pyams_content/component/paragraph/header.py Mon Aug 27 11:47:59 2018 +0200
@@ -16,24 +16,23 @@
# import standard library
# import interfaces
-from pyams_content.component.paragraph.interfaces import IParagraphFactory
-from pyams_content.component.paragraph.interfaces.header import IHeaderParagraph, HEADER_PARAGRAPH_TYPE, \
- HEADER_PARAGRAPH_RENDERERS, HEADER_PARAGRAPH_NAME
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
-from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
+from pyams_content.component.paragraph.interfaces.header import IHeaderParagraph, HEADER_PARAGRAPH_RENDERERS, \
+ HEADER_PARAGRAPH_NAME
+from pyams_content.features.checker.interfaces import IContentChecker, ERROR_VALUE
+from pyams_i18n.interfaces import II18n
# import packages
-from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
+from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker
from pyams_content.features.renderer import RenderersVocabulary
from pyams_utils.adapter import adapter_config
from pyams_utils.factory import factory_config
-from pyams_utils.registry import utility_config, get_utility
from pyams_utils.text import get_text_start
-from pyams_utils.traversing import get_parent
from pyams_utils.vocabulary import vocabulary_config
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
+from pyams_content import _
+
@implementer(IHeaderParagraph)
@factory_config(provided=IHeaderParagraph)
@@ -52,37 +51,15 @@
renderer = FieldProperty(IHeaderParagraph['renderer'])
-@utility_config(name=HEADER_PARAGRAPH_TYPE, provides=IParagraphFactory)
-class HeaderParagraphFactory(BaseParagraphFactory):
- """Header paragraph factory"""
-
- name = HEADER_PARAGRAPH_NAME
- content_type = HeaderParagraph
-
-
@adapter_config(context=IHeaderParagraph, provides=IContentChecker)
class HeaderParagraphContentChecker(BaseParagraphContentChecker):
"""Header paragraph content checker"""
def inner_check(self, request):
- output = []
translate = request.localizer.translate
- manager = get_parent(self.context, II18nManager)
- if manager is not None:
- langs = manager.get_languages()
- else:
- negotiator = get_utility(INegotiator)
- langs = (negotiator.server_language, )
- i18n = II18n(self.context)
- for lang in langs:
- value = i18n.get_attribute('header', lang, request)
- if not value:
- field_title = translate(IHeaderParagraph['header'].title)
- if len(langs) == 1:
- output.append(translate(MISSING_VALUE).format(field=field_title))
- else:
- output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
- return output
+ field_title = translate(IHeaderParagraph['header'].title)
+ return [translate(ERROR_VALUE).format(field=field_title,
+ message=_("This paragraph type is deprecated and should be removed!")), ]
@vocabulary_config(name=HEADER_PARAGRAPH_RENDERERS)