Added custom stylesheets and scripts to properties edit form
authorThierry Florac <tflorac@ulthar.net>
Wed, 12 Dec 2018 09:41:24 +0100
changeset 102 a6f0e6089417
parent 101 4c5436556f81
child 103 fb8dcfb17ced
Added custom stylesheets and scripts to properties edit form
src/pyams_zmi/zmi/skin.py
--- a/src/pyams_zmi/zmi/skin.py	Wed Oct 24 16:36:05 2018 +0200
+++ b/src/pyams_zmi/zmi/skin.py	Wed Dec 12 09:41:24 2018 +0100
@@ -9,31 +9,25 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
-
-from pyams_form.group import NamedWidgetsGroup
 
 __docformat__ = 'restructuredtext'
 
+from pyramid.view import view_config
+from z3c.form import field
+from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
 
-# import standard library
-
-# import interfaces
+from pyams_form.form import AJAXEditForm
+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_utils.interfaces import MANAGE_SKIN_PERMISSION
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.form import AdminDialogEditForm
 from pyams_zmi.interfaces.menu import IPropertiesMenu
 from pyams_zmi.layer import IAdminLayer
 
-# import packages
-from pyams_form.form import AJAXEditForm
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_skin.viewlet.menu import MenuItem, MenuDivider
-from pyams_viewlet.viewlet import viewlet_config
-from pyams_zmi.form import AdminDialogEditForm
-from pyramid.view import view_config
-from z3c.form import field
-
 from pyams_zmi import _
 
 
@@ -72,10 +66,12 @@
     @property
     def fields(self):
         if self.context.can_inherit_skin:
-            fields = field.Fields(IUserSkinnable).select('no_inherit_skin', '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')
+            fields = field.Fields(IUserSkinnable).select('skin', 'custom_stylesheet', 'editor_stylesheet',
+                                                         'custom_script')
         return fields
 
     ajax_handler = 'user-skin-properties.json'
@@ -84,7 +80,8 @@
     def updateGroups(self):
         if self.context.can_inherit_skin:
             self.add_group(NamedWidgetsGroup(self, 'skin', self.widgets,
-                                             ('no_inherit_skin', 'skin'),
+                                             ('no_inherit_skin', 'skin', 'custom_stylesheet',
+                                              'editor_stylesheet', 'custom_script'),
                                              legend=_("Don't inherit parent skin"),
                                              css_class='inner',
                                              switch=True,