diff -r 3599d25c7f10 -r 837612af4dc3 src/pyams_content/component/illustration/zmi/paragraph.py --- a/src/pyams_content/component/illustration/zmi/paragraph.py Thu Jan 17 12:41:14 2019 +0100 +++ b/src/pyams_content/component/illustration/zmi/paragraph.py Thu Jan 17 16:42:32 2019 +0100 @@ -13,22 +13,20 @@ __docformat__ = 'restructuredtext' from transaction.interfaces import ITransactionManager -from z3c.form import button, field +from z3c.form import button from z3c.form.interfaces import INPUT_MODE from zope.interface import implementer from pyams_content.component.illustration import IBasicIllustration from pyams_content.component.illustration.interfaces import IBasicIllustrationTarget, IIllustration, \ IIllustrationParagraph, ILLUSTRATION_PARAGRAPH_TYPE -from pyams_content.component.illustration.paragraph import Illustration -from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget +from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \ - BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \ + BaseParagraphAddForm, BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, \ get_json_paragraph_refresh_event from pyams_content.component.paragraph.zmi.container import ParagraphContainerCounterBase from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerTable, IParagraphContainerView, \ IParagraphInnerEditor, IParagraphTitleToolbar -from pyams_content.features.renderer.zmi.widget import RendererFieldWidget from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION from pyams_form.form import ajax_config from pyams_form.interfaces.form import IInnerForm @@ -39,7 +37,6 @@ from pyams_utils.adapter import adapter_config from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION from pyams_viewlet.viewlet import viewlet_config -from pyams_zmi.form import AdminDialogAddForm from pyams_content import _ @@ -63,23 +60,18 @@ permission=MANAGE_CONTENT_PERMISSION) @ajax_config(name='add-illustration.json', context=IParagraphContainerTarget, layer=IPyAMSLayer, base=BaseParagraphAJAXAddForm) -class IllustrationAddForm(AdminDialogAddForm): +class IllustrationAddForm(BaseParagraphAddForm): """Illustration add form""" legend = _("Add new illustration") dialog_class = 'modal-large' - icon_css_class = 'fa fa-fw fa-file-image-o' - fields = field.Fields(IIllustrationParagraph).select('data', 'title', 'alt_title', - 'author', 'description', 'renderer') + content_interface = IIllustrationParagraph - edit_permission = MANAGE_CONTENT_PERMISSION - - def create(self, data): - return Illustration() - - def add(self, object): - IParagraphContainer(self.context).append(object) + @property + def fields(self): + return super(IllustrationAddForm, self).fields \ + .select('data', 'title', 'alt_title', 'author', 'description', 'renderer') @pagelet_config(name='properties.html', context=IIllustrationParagraph, layer=IPyAMSLayer, @@ -93,13 +85,13 @@ legend = _("Edit illustration properties") dialog_class = 'modal-large' - icon_css_class = 'fa fa-fw fa-file-image-o' + + content_interface = IIllustrationParagraph - fields = field.Fields(IIllustrationParagraph).select('data', 'title', 'alt_title', - 'author', 'description', 'renderer') - fields['renderer'].widgetFactory = RendererFieldWidget - - edit_permission = MANAGE_CONTENT_PERMISSION + @property + def fields(self): + return super(IllustrationPropertiesEditForm, self).fields \ + .select('data', 'title', 'alt_title', 'author', 'description', 'renderer') def get_ajax_output(self, changes): output = super(self.__class__, self).get_ajax_output(changes)