Added skin properteis edit form
authorThierry Florac <thierry.florac@onf.fr>
Mon, 10 Oct 2016 15:27:43 +0200
changeset 21 4d8d6d0caecb
parent 20 e9fa6f0422d8
child 22 7d7f092df887
Added skin properteis edit form
src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.mo
src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.po
src/pyams_zmi/locales/pyams_zmi.pot
src/pyams_zmi/site.py
src/pyams_zmi/skin.py
Binary file src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.mo has changed
--- a/src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.po	Mon Jun 20 15:53:55 2016 +0200
+++ b/src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.po	Mon Oct 10 15:27:43 2016 +0200
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2016-06-15 11:29+0200\n"
+"POT-Creation-Date: 2016-10-10 14:42+0200\n"
 "PO-Revision-Date: 2015-02-04 09:50+0100\n"
 "Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
 "Language-Team: French <traduc@traduc.org>\n"
@@ -16,10 +16,18 @@
 "Generated-By: Lingua 3.8\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-#: src/pyams_zmi/skin.py:32
+#: src/pyams_zmi/skin.py:40
 msgid "PyAMS management skin"
 msgstr "Skin d'administration PyAMS"
 
+#: src/pyams_zmi/skin.py:53
+msgid "Graphic theme..."
+msgstr "Thème graphique..."
+
+#: src/pyams_zmi/skin.py:70
+msgid "Graphic theme elements"
+msgstr "Thème graphique"
+
 #: src/pyams_zmi/control_panel.py:62
 msgid "Utilities"
 msgstr "Utilitaires"
@@ -28,40 +36,40 @@
 msgid "Site utilities"
 msgstr "Utilitaires du site"
 
-#: src/pyams_zmi/control_panel.py:87
+#: src/pyams_zmi/control_panel.py:86
 msgid "Delete utility"
 msgstr "Supprimer cet utilitaire"
 
-#: src/pyams_zmi/control_panel.py:118 src/pyams_zmi/control_panel.py:248
-#: src/pyams_zmi/control_panel.py:312 src/pyams_zmi/viewlet/menu/__init__.py:60
+#: src/pyams_zmi/control_panel.py:117 src/pyams_zmi/control_panel.py:247
+#: src/pyams_zmi/control_panel.py:311 src/pyams_zmi/viewlet/menu/__init__.py:60
 msgid "Control panel"
 msgstr "Panneau de configuration"
 
-#: src/pyams_zmi/control_panel.py:152
+#: src/pyams_zmi/control_panel.py:151
 msgid "Component"
 msgstr "Composant"
 
-#: src/pyams_zmi/control_panel.py:174
+#: src/pyams_zmi/control_panel.py:173
 msgid "Registered interface"
 msgstr "Interface enregistrée"
 
-#: src/pyams_zmi/control_panel.py:189
+#: src/pyams_zmi/control_panel.py:188
 msgid "Name"
 msgstr "Nom"
 
-#: src/pyams_zmi/control_panel.py:209
+#: src/pyams_zmi/control_panel.py:208
 msgid "Local registrations"
 msgstr "Registre local"
 
-#: src/pyams_zmi/control_panel.py:218
+#: src/pyams_zmi/control_panel.py:217
 msgid "Local utilities registrations"
 msgstr "Registre local des composants"
 
-#: src/pyams_zmi/control_panel.py:255
+#: src/pyams_zmi/control_panel.py:254
 msgid "Local registry utilities"
 msgstr "Le registre local des composants"
 
-#: src/pyams_zmi/control_panel.py:256
+#: src/pyams_zmi/control_panel.py:255
 msgid ""
 "A local registry is a registry defining utilities stored into\n"
 "site's Object Database (ZODB).\n"
@@ -80,19 +88,19 @@
 "Vous pouvez gérer ces composants et modifier leurs propriétés pour changer "
 "le comportement du site sans modifier l'application."
 
-#: src/pyams_zmi/control_panel.py:273
+#: src/pyams_zmi/control_panel.py:272
 msgid "Global registrations"
 msgstr "Registre global"
 
-#: src/pyams_zmi/control_panel.py:282
+#: src/pyams_zmi/control_panel.py:281
 msgid "Global utilities registrations"
 msgstr "Registre global des composants"
 
-#: src/pyams_zmi/control_panel.py:319
+#: src/pyams_zmi/control_panel.py:318
 msgid "Global registry utilities"
 msgstr "Le registre global des composants"
 
-#: src/pyams_zmi/control_panel.py:320
+#: src/pyams_zmi/control_panel.py:319
 msgid ""
 "The global registry groups local utilities as well as utilities registered "
 "outside\n"
@@ -109,15 +117,15 @@
 "inclusions de paquets ou des directives ZCML) et ne peuvent être modifiés "
 "sans modifier la configuration du site."
 
-#: src/pyams_zmi/control_panel.py:197
+#: src/pyams_zmi/control_panel.py:196
 msgid "< no name >"
 msgstr "< pas de nom >"
 
-#: src/pyams_zmi/control_panel.py:130
+#: src/pyams_zmi/control_panel.py:129
 msgid "No provided object_name argument!"
 msgstr "L'argument 'object_name' n'a pas été fourni !"
 
-#: src/pyams_zmi/control_panel.py:135
+#: src/pyams_zmi/control_panel.py:134
 msgid "Given utility name doesn't exist!"
 msgstr "L'utilitaire indiqué n'existe pas !"
 
@@ -133,7 +141,7 @@
 msgid "Back-office properties..."
 msgstr "Propriétés du back-office..."
 
-#: src/pyams_zmi/site.py:146
+#: src/pyams_zmi/site.py:140
 msgid "Update site back-office properties"
 msgstr "Mise à jour des propriétés du back-office du site"
 
--- a/src/pyams_zmi/locales/pyams_zmi.pot	Mon Jun 20 15:53:55 2016 +0200
+++ b/src/pyams_zmi/locales/pyams_zmi.pot	Mon Oct 10 15:27:43 2016 +0200
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2016-06-15 11:29+0200\n"
+"POT-Creation-Date: 2016-10-10 14:42+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,10 +16,18 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Lingua 3.8\n"
 
-#: ./src/pyams_zmi/skin.py:32
+#: ./src/pyams_zmi/skin.py:40
 msgid "PyAMS management skin"
 msgstr ""
 
+#: ./src/pyams_zmi/skin.py:53
+msgid "Graphic theme..."
+msgstr ""
+
+#: ./src/pyams_zmi/skin.py:70
+msgid "Graphic theme elements"
+msgstr ""
+
 #: ./src/pyams_zmi/control_panel.py:62
 msgid "Utilities"
 msgstr ""
@@ -28,41 +36,41 @@
 msgid "Site utilities"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:87
+#: ./src/pyams_zmi/control_panel.py:86
 msgid "Delete utility"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:118 ./src/pyams_zmi/control_panel.py:248
-#: ./src/pyams_zmi/control_panel.py:312
+#: ./src/pyams_zmi/control_panel.py:117 ./src/pyams_zmi/control_panel.py:247
+#: ./src/pyams_zmi/control_panel.py:311
 #: ./src/pyams_zmi/viewlet/menu/__init__.py:60
 msgid "Control panel"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:152
+#: ./src/pyams_zmi/control_panel.py:151
 msgid "Component"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:174
+#: ./src/pyams_zmi/control_panel.py:173
 msgid "Registered interface"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:189
+#: ./src/pyams_zmi/control_panel.py:188
 msgid "Name"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:209
+#: ./src/pyams_zmi/control_panel.py:208
 msgid "Local registrations"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:218
+#: ./src/pyams_zmi/control_panel.py:217
 msgid "Local utilities registrations"
 msgstr ""
 
+#: ./src/pyams_zmi/control_panel.py:254
+msgid "Local registry utilities"
+msgstr ""
+
 #: ./src/pyams_zmi/control_panel.py:255
-msgid "Local registry utilities"
-msgstr ""
-
-#: ./src/pyams_zmi/control_panel.py:256
 msgid ""
 "A local registry is a registry defining utilities stored into\n"
 "site's Object Database (ZODB).\n"
@@ -71,19 +79,19 @@
 "modifying the application."
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:273
+#: ./src/pyams_zmi/control_panel.py:272
 msgid "Global registrations"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:282
+#: ./src/pyams_zmi/control_panel.py:281
 msgid "Global utilities registrations"
 msgstr ""
 
+#: ./src/pyams_zmi/control_panel.py:318
+msgid "Global registry utilities"
+msgstr ""
+
 #: ./src/pyams_zmi/control_panel.py:319
-msgid "Global registry utilities"
-msgstr ""
-
-#: ./src/pyams_zmi/control_panel.py:320
 msgid ""
 "The global registry groups local utilities as well as utilities registered outside\n"
 "site's Object Database (ZODB).\n"
@@ -92,15 +100,15 @@
 "without modifying site configuration."
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:197
+#: ./src/pyams_zmi/control_panel.py:196
 msgid "< no name >"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:130
+#: ./src/pyams_zmi/control_panel.py:129
 msgid "No provided object_name argument!"
 msgstr ""
 
-#: ./src/pyams_zmi/control_panel.py:135
+#: ./src/pyams_zmi/control_panel.py:134
 msgid "Given utility name doesn't exist!"
 msgstr ""
 
@@ -116,7 +124,7 @@
 msgid "Back-office properties..."
 msgstr ""
 
-#: ./src/pyams_zmi/site.py:146
+#: ./src/pyams_zmi/site.py:140
 msgid "Update site back-office properties"
 msgstr ""
 
--- a/src/pyams_zmi/site.py	Mon Jun 20 15:53:55 2016 +0200
+++ b/src/pyams_zmi/site.py	Mon Oct 10 15:27:43 2016 +0200
@@ -29,7 +29,7 @@
 from pyams_form.form import AJAXEditForm
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.page import DefaultPageHeaderAdapter
-from pyams_skin.viewlet.menu import MenuItem, MenuDivider
+from pyams_skin.viewlet.menu import MenuItem
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 from pyams_viewlet.manager import viewletmanager_config
 from pyams_viewlet.viewlet import viewlet_config
@@ -132,12 +132,6 @@
     modal_target = True
 
 
-@viewlet_config(name='back-office-properties.divider', context=ISiteRoot, layer=IAdminLayer, manager=IPropertiesMenu,
-                permission=MANAGE_SYSTEM_PERMISSION, weight=2)
-class BackOfficePropertiesMenuDivider(MenuDivider):
-    """Back-office properties menu divider"""
-
-
 @pagelet_config(name='back-office-properties.html', context=ISiteRoot, layer=IPyAMSLayer,
                 permission=MANAGE_SYSTEM_PERMISSION)
 class BackOfficePropertiesEditForm(AdminDialogEditForm):
--- a/src/pyams_zmi/skin.py	Mon Jun 20 15:53:55 2016 +0200
+++ b/src/pyams_zmi/skin.py	Mon Oct 10 15:27:43 2016 +0200
@@ -9,6 +9,9 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyramid.view import view_config
+
+from pyams_form.form import AJAXEditForm
 
 __docformat__ = 'restructuredtext'
 
@@ -16,13 +19,21 @@
 # import standard library
 
 # import interfaces
-from pyams_skin.interfaces import ISkin
+from pyams_skin.interfaces import ISkin, IUserSkinnable
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION, MANAGE_SYSTEM_PERMISSION
+from pyams_zmi.interfaces.menu import IPropertiesMenu
 from pyams_zmi.layer import IAdminLayer
 
 # import packages
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.viewlet.menu import MenuItem, MenuDivider
 from pyams_utils.registry import utility_config
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.form import AdminDialogEditForm
+from z3c.form import field
 
-from pyams_skin import _
+from pyams_zmi import _
 
 
 @utility_config(name='PyAMS admin skin', provides=ISkin)
@@ -31,3 +42,50 @@
 
     label = _("PyAMS management skin")
     layer = IAdminLayer
+
+
+#
+# User skinnable properties configuration
+#
+
+@viewlet_config(name='user-skin-properties.menu', context=IUserSkinnable, layer=IAdminLayer, manager=IPropertiesMenu,
+                permission=VIEW_SYSTEM_PERMISSION, weight=5)
+class UserSkinnablePropertiesMenuItem(MenuItem):
+    """User skin properties menu"""
+
+    label = _("Graphic theme...")
+    icon_class = 'fa-paint-brush'
+    url = 'user-skin-properties.html'
+    modal_target = True
+
+
+@viewlet_config(name='user-skin-properties.divider', context=IUserSkinnable, layer=IAdminLayer, manager=IPropertiesMenu,
+                permission=VIEW_SYSTEM_PERMISSION, weight=6)
+class UserSkinnablePropertiesMenuDivider(MenuDivider):
+    """User skin properties menu divider"""
+
+
+@pagelet_config(name='user-skin-properties.html', context=IUserSkinnable, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
+class UserSkinnablePropertiesEditForm(AdminDialogEditForm):
+    """User skin properties edit form"""
+
+    legend = _("Graphic theme elements")
+    label_css_class = 'control-label col-md-4'
+    input_css_class = 'col-md-8'
+
+    @property
+    def fields(self):
+        fields = field.Fields(IUserSkinnable)
+        if not self.context.can_inherit_skin:
+            fields = fields.omit('inherit_skin')
+        return fields
+
+    ajax_handler = 'user-skin-properties.json'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
+
+
+@view_config(name='user-skin-properties.json', context=IUserSkinnable, request_type=IPyAMSLayer,
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
+class UserSkinnablePropertiesAJAXEditForm(AJAXEditForm, UserSkinnablePropertiesEditForm):
+    """User skin properties edit form, JSON renderer"""