Use base paragraph edit forms
authorThierry Florac <thierry.florac@onf.fr>
Fri, 10 Nov 2017 11:54:55 +0100
changeset 253 80837cd25447
parent 252 2dafc720b378
child 254 eadd658a8416
Use base paragraph edit forms
src/pyams_content/component/gallery/zmi/paragraph.py
--- a/src/pyams_content/component/gallery/zmi/paragraph.py	Fri Nov 10 11:53:47 2017 +0100
+++ b/src/pyams_content/component/gallery/zmi/paragraph.py	Fri Nov 10 11:54:55 2017 +0100
@@ -20,9 +20,8 @@
 from pyams_content.component.gallery.zmi.interfaces import IGalleryImagesView
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
     IParagraphSummary
-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, IInnerSubForm
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IWidgetTitleViewletManager
@@ -32,16 +31,14 @@
 # import packages
 from pyams_content.component.gallery.paragraph import Gallery
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu
-from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
+    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm
 from pyams_content.shared.common.zmi import WfSharedContentPermissionMixin
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.toolbar import ToolbarAction
 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, InnerAdminDisplayForm
+from pyams_zmi.form import AdminDialogAddForm, InnerAdminDisplayForm
 from pyramid.view import view_config
 from z3c.form import field, button
 from zope.interface import implementer, Interface
@@ -49,7 +46,7 @@
 from pyams_content import _
 
 
-@viewlet_config(name='add-gallery.menu', context=IParagraphContainerTarget, view=ParagraphContainerView,
+@viewlet_config(name='add-gallery.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
                 layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=65)
 class GalleryAddMenu(BaseParagraphAddMenu):
     """Gallery add menu"""
@@ -92,14 +89,9 @@
 
 @pagelet_config(name='properties.html', context=IGalleryParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
-class GalleryPropertiesEditForm(AdminDialogEditForm):
+class GalleryPropertiesEditForm(BaseParagraphPropertiesEditForm):
     """Gallery properties edit form"""
 
-    @property
-    def title(self):
-        content = get_parent(self.context, IWfSharedContent)
-        return II18n(content).query_attribute('title', request=self.request)
-
     legend = _("Edit gallery properties")
     icon_css_class = 'fa fa-fw fa-picture-o'