src/pyams_content/component/paragraph/keynumber.py
changeset 586 28445044f6e3
parent 558 d9c6b1d7fefa
child 587 978dc30214ce
equal deleted inserted replaced
585:9fa8e9776bda 586:28445044f6e3
    18 
    18 
    19 # import interfaces
    19 # import interfaces
    20 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    20 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    21 from pyams_content.component.paragraph.interfaces.keynumber import IKeyNumber, IKeyNumberContainer, \
    21 from pyams_content.component.paragraph.interfaces.keynumber import IKeyNumber, IKeyNumberContainer, \
    22     IKeyNumberContainerTarget, KEYNUMBER_CONTAINER_KEY, IKeyNumberParagraph, KEYNUMBER_PARAGRAPH_TYPE, \
    22     IKeyNumberContainerTarget, KEYNUMBER_CONTAINER_KEY, IKeyNumberParagraph, KEYNUMBER_PARAGRAPH_TYPE, \
    23     KEYNUMBER_PARAGRAPH_RENDERERS
    23     KEYNUMBER_PARAGRAPH_RENDERERS, KEYNUMBER_PARAGRAPH_NAME
    24 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    24 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    25 from pyams_form.interfaces.form import IFormContextPermissionChecker
    25 from pyams_form.interfaces.form import IFormContextPermissionChecker
    26 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    26 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    27 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
    27 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
    28 from zope.location.interfaces import ISublocations
    28 from zope.location.interfaces import ISublocations
    44 from zope.container.ordered import OrderedContainer
    44 from zope.container.ordered import OrderedContainer
    45 from zope.interface import implementer
    45 from zope.interface import implementer
    46 from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
    46 from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
    47 from zope.location import locate
    47 from zope.location import locate
    48 from zope.schema.fieldproperty import FieldProperty
    48 from zope.schema.fieldproperty import FieldProperty
    49 
       
    50 from pyams_content import _
       
    51 
    49 
    52 
    50 
    53 #
    51 #
    54 # Key number class and adapters
    52 # Key number class and adapters
    55 #
    53 #
   178 
   176 
   179 @adapter_config(name='keynumbers', context=IKeyNumberContainerTarget, provides=IContentChecker)
   177 @adapter_config(name='keynumbers', context=IKeyNumberContainerTarget, provides=IContentChecker)
   180 class KeyNumberContainerContentChecker(BaseContentChecker):
   178 class KeyNumberContainerContentChecker(BaseContentChecker):
   181     """Key numbers container content checker"""
   179     """Key numbers container content checker"""
   182 
   180 
   183     label = _("Key numbers")
   181     label = KEYNUMBER_PARAGRAPH_NAME
   184     sep = '\n'
   182     sep = '\n'
   185     weight = 200
   183     weight = 200
   186 
   184 
   187     def inner_check(self, request):
   185     def inner_check(self, request):
   188         output = []
   186         output = []
   202 @factory_config(provided=IKeyNumberParagraph)
   200 @factory_config(provided=IKeyNumberParagraph)
   203 class KeyNumberParagraph(BaseParagraph):
   201 class KeyNumberParagraph(BaseParagraph):
   204     """Key numbers paragraph"""
   202     """Key numbers paragraph"""
   205 
   203 
   206     icon_class = 'fa-list-ol'
   204     icon_class = 'fa-list-ol'
   207     icon_hint = _("Key numbers")
   205     icon_hint = KEYNUMBER_PARAGRAPH_NAME
   208 
   206 
   209     renderer = FieldProperty(IKeyNumberParagraph['renderer'])
   207     renderer = FieldProperty(IKeyNumberParagraph['renderer'])
   210 
   208 
   211 
   209 
   212 @utility_config(name=KEYNUMBER_PARAGRAPH_TYPE, provides=IParagraphFactory)
   210 @utility_config(name=KEYNUMBER_PARAGRAPH_TYPE, provides=IParagraphFactory)
   213 class KeyNumberParagraphFactory(BaseParagraphFactory):
   211 class KeyNumberParagraphFactory(BaseParagraphFactory):
   214     """Key numbers paragraph factory"""
   212     """Key numbers paragraph factory"""
   215 
   213 
   216     name = _("Key numbers paragraph")
   214     name = KEYNUMBER_PARAGRAPH_NAME
   217     content_type = KeyNumberParagraph
   215     content_type = KeyNumberParagraph
   218 
   216 
   219 
   217 
   220 @adapter_config(context=IKeyNumberParagraph, provides=IContentChecker)
   218 @adapter_config(context=IKeyNumberParagraph, provides=IContentChecker)
   221 class KeyNumberParagraphContentChecker(BaseParagraphContentChecker):
   219 class KeyNumberParagraphContentChecker(BaseParagraphContentChecker):