--- a/src/pyams_zmi/zmi/skin.py Wed Dec 12 09:41:24 2018 +0100
+++ b/src/pyams_zmi/zmi/skin.py Wed Dec 12 11:06:36 2018 +0100
@@ -12,16 +12,15 @@
__docformat__ = 'restructuredtext'
-from pyramid.view import view_config
from z3c.form import field
from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
-from pyams_form.form import AJAXEditForm
+from pyams_form.form import ajax_config
from pyams_form.group import NamedWidgetsGroup
from pyams_pagelet.pagelet import pagelet_config
from pyams_skin.interfaces import IUserSkinnable
from pyams_skin.layer import IPyAMSLayer
-from pyams_skin.viewlet.menu import MenuItem, MenuDivider
+from pyams_skin.viewlet.menu import MenuDivider, MenuItem
from pyams_utils.interfaces import MANAGE_SKIN_PERMISSION
from pyams_viewlet.viewlet import viewlet_config
from pyams_zmi.form import AdminDialogEditForm
@@ -54,6 +53,7 @@
@pagelet_config(name='user-skin-properties.html', context=IUserSkinnable, layer=IPyAMSLayer,
permission=MANAGE_SKIN_PERMISSION)
+@ajax_config(name='user-skin-properties.json', context=IUserSkinnable, layer=IPyAMSLayer)
class UserSkinnablePropertiesEditForm(AdminDialogEditForm):
"""User skin properties edit form"""
@@ -65,13 +65,12 @@
@property
def fields(self):
+ fields = field.Fields(IUserSkinnable).select('no_inherit_skin', 'skin', 'custom_stylesheet',
+ 'editor_stylesheet', 'custom_script')
if self.context.can_inherit_skin:
- fields = field.Fields(IUserSkinnable).select('no_inherit_skin', 'skin',
- 'custom_stylesheet', 'editor_stylesheet')
fields['no_inherit_skin'].widgetFactory = SingleCheckBoxFieldWidget
else:
- fields = field.Fields(IUserSkinnable).select('skin', 'custom_stylesheet', 'editor_stylesheet',
- 'custom_script')
+ fields = fields.omit('no_inherit_skin')
return fields
ajax_handler = 'user-skin-properties.json'
@@ -89,9 +88,3 @@
checkbox_mode='disable',
checkbox_field=IUserSkinnable['no_inherit_skin']))
super(UserSkinnablePropertiesEditForm, self).updateGroups()
-
-
-@view_config(name='user-skin-properties.json', context=IUserSkinnable, request_type=IPyAMSLayer,
- permission=MANAGE_SKIN_PERMISSION, renderer='json', xhr=True)
-class UserSkinnablePropertiesAJAXEditForm(AJAXEditForm, UserSkinnablePropertiesEditForm):
- """User skin properties edit form, JSON renderer"""