Refactored paragraph title interface
authorThierry Florac <thierry.florac@onf.fr>
Tue, 27 Nov 2018 15:37:04 +0100
changeset 1127 a76066afc55b
parent 1126 f3b3d2beb266
child 1128 1be970640518
Refactored paragraph title interface
src/pyams_content/component/paragraph/zmi/container.py
src/pyams_content/component/paragraph/zmi/frame.py
src/pyams_content/component/paragraph/zmi/html.py
src/pyams_content/component/paragraph/zmi/interfaces.py
src/pyams_content/component/paragraph/zmi/milestone.py
src/pyams_content/component/paragraph/zmi/verbatim.py
--- a/src/pyams_content/component/paragraph/zmi/container.py	Tue Nov 27 15:36:41 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/container.py	Tue Nov 27 15:37:04 2018 +0100
@@ -25,11 +25,11 @@
 
 from pyams_content.component.association.interfaces import IAssociationContainer
 from pyams_content.component.association.zmi import AssociationsContainerView
-from pyams_content.component.paragraph import BaseParagraph
+from pyams_content.component.paragraph import BaseParagraph, IParagraphTitle
 from pyams_content.component.paragraph.interfaces import IBaseParagraph, IParagraphContainer, IParagraphContainerTarget, \
     IParagraphFactorySettings
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerTable, IParagraphContainerView, \
-    IParagraphInnerEditor, IParagraphTitleToolbar, IParagraphTitleValue
+    IParagraphInnerEditor, IParagraphTitleToolbar
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
 from pyams_content.shared.common.zmi import WfModifiedContentColumnMixin
 from pyams_content.zmi import pyams_content
@@ -271,7 +271,7 @@
         return '<span class="title">{0}</span>'.format(super(ParagraphContainerBaseTitleColumn, self).renderCell(item))
 
     def getValue(self, obj):
-        adapter = self.request.registry.queryMultiAdapter((obj, self.request), IParagraphTitleValue)
+        adapter = self.request.registry.queryMultiAdapter((obj, self.request), IParagraphTitle)
         if adapter is not None:
             return adapter
         return II18n(obj).query_attribute('title', request=self.request) or BaseParagraph.empty_title
--- a/src/pyams_content/component/paragraph/zmi/frame.py	Tue Nov 27 15:36:41 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/frame.py	Tue Nov 27 15:37:04 2018 +0100
@@ -21,11 +21,11 @@
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
 from pyams_content.component.paragraph.frame import FrameParagraph
 from pyams_content.component.paragraph.interfaces import IBaseParagraph, IParagraphContainer, \
-    IParagraphContainerTarget, PARAGRAPH_HIDDEN_FIELDS
+    IParagraphContainerTarget, IParagraphTitle, PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.frame import FRAME_PARAGRAPH_TYPE, IFrameParagraph
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, IParagraphTitleValue, \
-    get_json_paragraph_toolbar_refresh_event, get_json_paragraph_refresh_event
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \
+    get_json_paragraph_refresh_event, get_json_paragraph_toolbar_refresh_event
 from pyams_content.component.paragraph.zmi.container import ParagraphContainerTable, \
     ParagraphTitleToolbarViewletManager
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, IParagraphInnerEditor
@@ -76,7 +76,7 @@
 # Framed text paragraph
 #
 
-@adapter_config(context=(IFrameParagraph, IPyAMSLayer), provides=IParagraphTitleValue)
+@adapter_config(context=(IFrameParagraph, IPyAMSLayer), provides=IParagraphTitle)
 def frame_paragraph_title_adapter(context, request):
     """Frame paragraph title adapter"""
     i18n = II18n(context)
--- a/src/pyams_content/component/paragraph/zmi/html.py	Tue Nov 27 15:36:41 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Tue Nov 27 15:37:04 2018 +0100
@@ -21,11 +21,11 @@
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
 from pyams_content.component.paragraph.html import HTMLParagraph, RawParagraph
 from pyams_content.component.paragraph.interfaces import IBaseParagraph, IParagraphContainer, \
-    IParagraphContainerTarget, IParagraphFactorySettings, PARAGRAPH_HIDDEN_FIELDS
+    IParagraphContainerTarget, IParagraphFactorySettings, IParagraphTitle, PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.html import HTML_PARAGRAPH_TYPE, IHTMLParagraph, IRawParagraph, \
     RAW_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, IParagraphTitleValue, \
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \
     get_json_paragraph_refresh_event, get_json_paragraph_toolbar_refresh_event
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, IParagraphInnerEditor
 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
@@ -183,7 +183,7 @@
         IParagraphContainer(self.context).append(object)
 
 
-@adapter_config(context=(IHTMLParagraph, IPyAMSLayer), provides=IParagraphTitleValue)
+@adapter_config(context=(IHTMLParagraph, IPyAMSLayer), provides=IParagraphTitle)
 def html_paragraph_title_adapter(context, request):
     """HTML paragraph title adapter"""
     i18n = II18n(context)
--- a/src/pyams_content/component/paragraph/zmi/interfaces.py	Tue Nov 27 15:36:41 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/interfaces.py	Tue Nov 27 15:37:04 2018 +0100
@@ -12,16 +12,11 @@
 
 __docformat__ = 'restructuredtext'
 
+from zope.interface import Interface
 
-# import standard library
-
-# import interfaces
 from pyams_form.interfaces.form import IInnerForm
 from pyams_viewlet.interfaces import IViewletManager
 
-# import packages
-from zope.interface import Interface
-
 
 class IParagraphContainerTable(Interface):
     """Paragraph container table marker interface"""
@@ -35,10 +30,6 @@
     """Paragraphs view parent form marker interface"""
 
 
-class IParagraphTitleValue(Interface):
-    """Paragraph title column value adapter"""
-
-
 class IParagraphTitleToolbar(IViewletManager):
     """Paragraph title toolbar viewlet manager"""
 
--- a/src/pyams_content/component/paragraph/zmi/milestone.py	Tue Nov 27 15:36:41 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/milestone.py	Tue Nov 27 15:37:04 2018 +0100
@@ -23,8 +23,8 @@
 from zope.interface import Interface, implementer
 from zope.schema.vocabulary import getVocabularyRegistry
 
-from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget, \
-    PARAGRAPH_HIDDEN_FIELDS
+from pyams_content.component.paragraph.interfaces import CONTENT_PARAGRAPHS_VOCABULARY, IParagraphContainer, \
+    IParagraphContainerTarget, PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.milestone import IMilestone, IMilestoneContainer, \
     IMilestoneContainerTarget, IMilestoneParagraph, MILESTONE_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.milestone import Milestone, MilestoneParagraph
@@ -268,7 +268,7 @@
         if target is None:
             return self.defaultValue
         try:
-            vocabulary = getVocabularyRegistry().get(obj, 'PyAMS content paragraphs')
+            vocabulary = getVocabularyRegistry().get(obj, CONTENT_PARAGRAPHS_VOCABULARY)
             return vocabulary.getTermByToken(obj.anchor).title
         except LookupError:
             return self.request.localizer.translate(_("(missing paragraph)")).format(obj.anchor)
--- a/src/pyams_content/component/paragraph/zmi/verbatim.py	Tue Nov 27 15:36:41 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/verbatim.py	Tue Nov 27 15:37:04 2018 +0100
@@ -17,13 +17,13 @@
 from zope.interface import implementer
 
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
-from pyams_content.component.paragraph import IBaseParagraph
+from pyams_content.component.paragraph import IBaseParagraph, IParagraphTitle
 from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget, \
     PARAGRAPH_HIDDEN_FIELDS
 from pyams_content.component.paragraph.interfaces.verbatim import IVerbatimParagraph, VERBATIM_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.verbatim import VerbatimParagraph
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, IParagraphTitleValue, \
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \
     get_json_paragraph_refresh_event
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, IParagraphInnerEditor
 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
@@ -83,7 +83,7 @@
         IParagraphContainer(self.context).append(object)
 
 
-@adapter_config(context=(IVerbatimParagraph, IPyAMSLayer), provides=IParagraphTitleValue)
+@adapter_config(context=(IVerbatimParagraph, IPyAMSLayer), provides=IParagraphTitle)
 def verbatim_paragraph_title_adapter(context, request):
     """Verbatim paragraph title adapter"""
     i18n = II18n(context)