Use base paragraph edit forms
authorThierry Florac <thierry.florac@onf.fr>
Fri, 10 Nov 2017 11:50:35 +0100
changeset 245 6b02caf97666
parent 244 175c2a77104d
child 246 fbb9edefeb58
Use base paragraph edit forms
src/pyams_content/component/paragraph/zmi/header.py
src/pyams_content/component/paragraph/zmi/html.py
src/pyams_content/component/paragraph/zmi/preview.py
src/pyams_content/component/paragraph/zmi/video.py
--- a/src/pyams_content/component/paragraph/zmi/header.py	Fri Nov 10 11:50:11 2017 +0100
+++ b/src/pyams_content/component/paragraph/zmi/header.py	Fri Nov 10 11:50:35 2017 +0100
@@ -19,9 +19,8 @@
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
     IParagraphSummary
 from pyams_content.component.paragraph.interfaces.header import IHeaderParagraph
-from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor
+from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
-from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_form.interfaces.form import IInnerForm, IEditFormButtons
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
@@ -31,14 +30,12 @@
 # import packages
 from pyams_content.component.paragraph.header import HeaderParagraph
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu
-from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config
-from pyams_utils.traversing import get_parent
 from pyams_viewlet.viewlet import viewlet_config, BaseContentProvider
-from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyams_zmi.form import AdminDialogAddForm
 from pyramid.view import view_config
 from z3c.form import field, button
 from zope.interface import implementer
@@ -46,7 +43,7 @@
 from pyams_content import _
 
 
-@viewlet_config(name='add-header-paragraph.menu', context=IParagraphContainerTarget, view=ParagraphContainerView,
+@viewlet_config(name='add-header-paragraph.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
                 layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=40)
 class HeaderParagraphAddMenu(BaseParagraphAddMenu):
     """Header paragraph add menu"""
@@ -89,14 +86,9 @@
 
 @pagelet_config(name='properties.html', context=IHeaderParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
-class HeaderParagraphPropertiesEditForm(AdminDialogEditForm):
+class HeaderParagraphPropertiesEditForm(BaseParagraphPropertiesEditForm):
     """Header paragraph properties edit form"""
 
-    @property
-    def title(self):
-        content = get_parent(self.context, IWfSharedContent)
-        return II18n(content).query_attribute('title', request=self.request)
-
     legend = _("Edit header paragraph properties")
     icon_css_class = 'fa fa-fw fa-header'
 
--- a/src/pyams_content/component/paragraph/zmi/html.py	Fri Nov 10 11:50:11 2017 +0100
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Fri Nov 10 11:50:35 2017 +0100
@@ -22,7 +22,7 @@
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
     IParagraphSummary
 from pyams_content.component.paragraph.interfaces.html import IHTMLParagraph
-from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor
+from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
 from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_form.interfaces.form import IInnerForm, IEditFormButtons
@@ -36,8 +36,8 @@
 from pyams_content.component.association.zmi import AssociationsTable
 from pyams_content.component.paragraph.html import HTMLParagraph
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu
-from pyams_content.component.paragraph.zmi.container import ParagraphContainerView, ParagraphContainerTable, \
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm
+from pyams_content.component.paragraph.zmi.container import ParagraphContainerTable, \
     ParagraphTitleToolbarViewletManager
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_template.template import template_config
@@ -45,7 +45,7 @@
 from pyams_utils.adapter import adapter_config
 from pyams_utils.traversing import get_parent
 from pyams_viewlet.viewlet import viewlet_config, BaseContentProvider
-from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyams_zmi.form import AdminDialogAddForm
 from pyramid.threadlocal import get_current_registry
 from pyramid.view import view_config
 from z3c.form import field, button
@@ -58,7 +58,7 @@
 # HTML paragraph
 #
 
-@viewlet_config(name='add-html-paragraph.menu', context=IParagraphContainerTarget, view=ParagraphContainerView,
+@viewlet_config(name='add-html-paragraph.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
                 layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=50)
 class HTMLParagraphAddMenu(BaseParagraphAddMenu):
     """HTML paragraph add menu"""
@@ -104,14 +104,9 @@
 
 @pagelet_config(name='properties.html', context=IHTMLParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
-class HTMLParagraphPropertiesEditForm(AdminDialogEditForm):
+class HTMLParagraphPropertiesEditForm(BaseParagraphPropertiesEditForm):
     """HTML paragraph properties edit form"""
 
-    @property
-    def title(self):
-        content = get_parent(self.context, IWfSharedContent)
-        return II18n(content).query_attribute('title', request=self.request)
-
     legend = _("Edit HTML paragraph properties")
     dialog_class = 'modal-max'
     icon_css_class = 'fa fa-fw fa-html5'
--- a/src/pyams_content/component/paragraph/zmi/preview.py	Fri Nov 10 11:50:11 2017 +0100
+++ b/src/pyams_content/component/paragraph/zmi/preview.py	Fri Nov 10 11:50:35 2017 +0100
@@ -18,7 +18,7 @@
 # import interfaces
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
     IParagraphSummary
-from pyams_content.shared.common.interfaces.zmi import IPreviewForm
+from pyams_content.features.preview.zmi.interfaces import IPreviewForm
 from pyams_form.interfaces.form import IWidgetsSuffixViewletsManager
 from pyams_i18n.interfaces import II18nManager
 from pyams_skin.layer import IPyAMSLayer
--- a/src/pyams_content/component/paragraph/zmi/video.py	Fri Nov 10 11:50:11 2017 +0100
+++ b/src/pyams_content/component/paragraph/zmi/video.py	Fri Nov 10 11:50:35 2017 +0100
@@ -20,9 +20,8 @@
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
     IParagraphSummary
 from pyams_content.component.paragraph.interfaces.video import IVideoParagraph
-from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor
+from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
-from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_form.interfaces.form import IInnerForm, IEditFormButtons
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
@@ -35,15 +34,13 @@
 from pyams_content.component.association.zmi import AssociationsTable
 from pyams_content.component.paragraph.video import VideoParagraph
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu
-from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm
 from pyams_form.group import NamedWidgetsGroup
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config
-from pyams_utils.traversing import get_parent
 from pyams_viewlet.viewlet import viewlet_config, BaseContentProvider
-from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyams_zmi.form import AdminDialogAddForm
 from pyramid.view import view_config
 from z3c.form import field, button
 from zope.interface import implementer
@@ -51,7 +48,7 @@
 from pyams_content import _
 
 
-@viewlet_config(name='add-video-paragraph.menu', context=IParagraphContainerTarget, view=ParagraphContainerView,
+@viewlet_config(name='add-video-paragraph.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
                 layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=70)
 class VideoParagraphAddMenu(BaseParagraphAddMenu):
     """Video paragraph add menu"""
@@ -106,14 +103,9 @@
 
 @pagelet_config(name='properties.html', context=IVideoParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
-class VideoParagraphPropertiesEditForm(AdminDialogEditForm):
+class VideoParagraphPropertiesEditForm(BaseParagraphPropertiesEditForm):
     """Video paragraph properties edit form"""
 
-    @property
-    def title(self):
-        content = get_parent(self.context, IWfSharedContent)
-        return II18n(content).query_attribute('title', request=self.request)
-
     legend = _("Edit video properties")
     dialog_class = 'modal-large'
     icon_css_class = 'fa fa-fw fa-film'