--- a/src/pyams_content/component/paragraph/keynumber.py Tue Jul 17 15:12:43 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-from pyams_content.component.paragraph.interfaces import IParagraphFactory
-from pyams_content.component.paragraph.interfaces.keynumber import IKeyNumberParagraph, KEYNUMBER_PARAGRAPH_TYPE, \
- KEYNUMBER_PARAGRAPH_RENDERERS, KEYNUMBER_PARAGRAPH_NAME
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
-from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
-
-# import packages
-from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory, 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 get_utility, utility_config
-from pyams_utils.request import check_request
-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
-
-
-@implementer(IKeyNumberParagraph)
-@factory_config(provided=IKeyNumberParagraph)
-class KeyNumberParagraph(BaseParagraph):
- """Key numbers paragraph"""
-
- icon_class = 'fa-dashboard'
- icon_hint = KEYNUMBER_PARAGRAPH_NAME
-
- renderer = FieldProperty(IKeyNumberParagraph['renderer'])
-
-
-@utility_config(name=KEYNUMBER_PARAGRAPH_TYPE, provides=IParagraphFactory)
-class KeyNumberParagraphFactory(BaseParagraphFactory):
- """Key numbers paragraph factory"""
-
- name = KEYNUMBER_PARAGRAPH_NAME
- content_type = KeyNumberParagraph
-
-
-@adapter_config(context=IKeyNumberParagraph, provides=IContentChecker)
-class KeyNumberParagraphContentChecker(BaseParagraphContentChecker):
- """Key numbers paragraph content checker"""
-
- @property
- def label(self):
- request = check_request()
- translate = request.localizer.translate
- return II18n(self.context).query_attribute('title', request) or \
- '({0})'.format(translate(self.context.icon_hint).lower())
-
- 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('title', lang, request)
- if not value:
- field_title = translate(IKeyNumberParagraph['title'].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
-
-
-@vocabulary_config(name=KEYNUMBER_PARAGRAPH_RENDERERS)
-class KeyNumberParagraphRendererVocabulary(RenderersVocabulary):
- """Key numbers paragraph renderers vocabulary"""
-
- content_interface = IKeyNumberParagraph