src/pyams_content/component/paragraph/milestone.py
changeset 555 8e8a14452567
parent 518 7384ea4d39d7
child 558 d9c6b1d7fefa
--- a/src/pyams_content/component/paragraph/milestone.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/milestone.py	Fri May 25 08:03:41 2018 +0200
@@ -34,8 +34,9 @@
 from pyams_catalog.utils import index_object
 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory, BaseParagraphContentChecker
 from pyams_content.features.checker import BaseContentChecker
-from pyams_content.features.renderer import RenderedContentMixin, IContentRenderer
+from pyams_content.features.renderer import RenderersVocabulary
 from pyams_utils.adapter import adapter_config, ContextAdapter
+from pyams_utils.factory import factory_config
 from pyams_utils.registry import get_current_registry, get_utility, utility_config
 from pyams_utils.request import check_request
 from pyams_utils.traversing import get_parent
@@ -47,7 +48,6 @@
 from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
 from zope.location import locate
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_content import _
 
@@ -221,7 +221,8 @@
 
 
 @implementer(IMilestoneParagraph)
-class MilestoneParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IMilestoneParagraph)
+class MilestoneParagraph(BaseParagraph):
     """Milestones paragraph"""
 
     icon_class = 'fa-arrows-h'
@@ -271,16 +272,7 @@
 
 
 @vocabulary_config(name=MILESTONE_PARAGRAPH_RENDERERS)
-class MilestoneParagraphRendererVocabulary(SimpleVocabulary):
+class MilestoneParagraphRendererVocabulary(RenderersVocabulary):
     """Milestones paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IMilestoneParagraph.providedBy(context):
-            context = MilestoneParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(MilestoneParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IMilestoneParagraph