--- a/src/pyams_content/shared/form/zmi/preview.py Wed Mar 14 10:27:27 2018 +0100
+++ b/src/pyams_content/shared/form/zmi/preview.py Thu Mar 15 09:32:48 2018 +0100
@@ -16,23 +16,22 @@
# import standard library
# import interfaces
-from pyams_content.features.preview.zmi.interfaces import IPreviewForm
+from pyams_content.features.renderer.interfaces import IContentRenderer
from pyams_content.shared.form.interfaces import IFormFieldContainerTarget, IFormFieldContainer
-from pyams_form.interfaces.form import IFormHelp, IWidgetsSuffixViewletsManager
+from pyams_form.interfaces.form import IFormHelp
from pyams_i18n.interfaces import II18n
from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
# import packages
+from pyams_content.features.renderer.zmi import BaseContentRenderer
+from pyams_form.form import InnerAddForm
from pyams_form.help import FormHelp
from pyams_utils.adapter import adapter_config
-from pyams_viewlet.viewlet import viewlet_config, Viewlet
-from pyams_zmi.form import InnerAdminAddForm
from z3c.form import field, button
from zope.interface import Interface
-class FormFieldContainerPreviewDisplayForm(InnerAdminAddForm):
+class FormFieldContainerPreviewDisplayForm(InnerAddForm):
"""Form fields container preview display form"""
@property
@@ -60,7 +59,8 @@
widget.widget_css_class = 'textarea'
-@adapter_config(context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldContainerPreviewDisplayForm), provides=IFormHelp)
+@adapter_config(context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldContainerPreviewDisplayForm),
+ provides=IFormHelp)
class FormFieldContainerPreviewHelp(FormHelp):
"""Form field container preview help adapter"""
@@ -76,17 +76,20 @@
message_format = 'text'
-@viewlet_config(name='form-fields-preview', context=IFormFieldContainerTarget, layer=IPyAMSLayer,
- view=IPreviewForm, manager=IWidgetsSuffixViewletsManager,
- permission=VIEW_SYSTEM_PERMISSION, weight=80)
-class FormFieldContainerPreview(Viewlet):
+@adapter_config(name='form-preview', context=(IFormFieldContainerTarget, IPyAMSLayer),
+ provides=IContentRenderer)
+class FormFieldContainerPreview(BaseContentRenderer):
"""Form field container preview"""
+ weight = 20
display_form = None
+ def __init__(self, context, request):
+ super(FormFieldContainerPreview, self).__init__(context, request)
+ self.display_form = FormFieldContainerPreviewDisplayForm(context, self.request)
+
def update(self):
super(FormFieldContainerPreview, self).update()
- self.display_form = FormFieldContainerPreviewDisplayForm(self.context, self.request)
self.display_form.update()
def render(self):