# HG changeset patch # User Thierry Florac # Date 1536075098 -7200 # Node ID 27cf196f066cd328222257e2522e811641be02c1 # Parent 4ac5a1814dc04ce594f84bf50421336e02237e76 Updated portal template selection form diff -r 4ac5a1814dc0 -r 27cf196f066c src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.mo Binary file src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.mo has changed diff -r 4ac5a1814dc0 -r 27cf196f066c src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.po --- a/src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.po Tue Sep 04 14:48:00 2018 +0200 +++ b/src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.po Tue Sep 04 17:31:38 2018 +0200 @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2018-09-04 14:12+0200\n" +"POT-Creation-Date: 2018-09-04 17:24+0200\n" "PO-Revision-Date: 2015-05-12 12:10+0200\n" "Last-Translator: Thierry Florac \n" "Language-Team: French \n" @@ -28,11 +28,11 @@ msgid "Portal templates manager" msgstr "Gestionnaire des modèles" -#: src/pyams_portal/zmi/portlet.py:62 +#: src/pyams_portal/zmi/portlet.py:61 msgid "Edit portlet settings" msgstr "Propriétés du composant" -#: src/pyams_portal/zmi/portlet.py:108 +#: src/pyams_portal/zmi/portlet.py:107 msgid "" "WARNING: Portlet properties are saved automatically when changing inherit " "mode!!" @@ -41,34 +41,34 @@ "modèle ou du parent en (dé)cochant la case ci-dessous, cette modification " "est enregistrée immédiatement sans attendre votre confirmation !!" -#: src/pyams_portal/zmi/portlet.py:118 +#: src/pyams_portal/zmi/portlet.py:117 msgid "Main properties" msgstr "Propriétés" -#: src/pyams_portal/zmi/portlet.py:176 +#: src/pyams_portal/zmi/portlet.py:175 #: src/pyams_portal/zmi/templates/renderer-input.pt:4 msgid "Edit renderer properties" msgstr "Propriétés de ce mode de rendu" -#: src/pyams_portal/zmi/portlet.py:83 src/pyams_portal/zmi/portlet.py:89 +#: src/pyams_portal/zmi/portlet.py:82 src/pyams_portal/zmi/portlet.py:88 msgid "Override template settings" msgstr "Remplacer le paramétrage du modèle sélectionné" -#: src/pyams_portal/zmi/portlet.py:87 +#: src/pyams_portal/zmi/portlet.py:86 msgid "Override parent settings" msgstr "Remplacer le paramétrage du modèle du parent" -#: src/pyams_portal/zmi/portlet.py:57 +#: src/pyams_portal/zmi/portlet.py:56 #, python-format msgid "Local portal template - {0}" msgstr "Modèle de présentation local - {0}" -#: src/pyams_portal/zmi/portlet.py:59 +#: src/pyams_portal/zmi/portlet.py:58 #, python-format msgid "« {0} » portal template - {1}" msgstr "Modèle de présentation « {0} » - {1}" -#: src/pyams_portal/zmi/portlet.py:156 +#: src/pyams_portal/zmi/portlet.py:155 msgid "" "You changed renderer selection. Don't omit to update new renderer " "properties..." @@ -76,19 +76,19 @@ "Vous avez changé de mode de rendu. N'oubliez pas de vérifier les propriétés " "du nouveau mode de rendu sélectionné !" -#: src/pyams_portal/zmi/page.py:66 +#: src/pyams_portal/zmi/page.py:73 msgid "Presentation" msgstr "Présentation" -#: src/pyams_portal/zmi/page.py:129 +#: src/pyams_portal/zmi/page.py:95 msgid "Edit template configuration" msgstr "Choix du modèle de présentation" -#: src/pyams_portal/zmi/page.py:130 -msgid "Override parent template" -msgstr "Ne pas hériter du modèle de présentation du parent" +#: src/pyams_portal/zmi/page.py:96 +msgid "Inherit parent template" +msgstr "Hériter du modèle de présentation du parent" -#: src/pyams_portal/zmi/page.py:203 +#: src/pyams_portal/zmi/page.py:153 msgid "" "If you choose a shared template, you can only adjust settings of each " "portlet individually but can't change portlets list or page configuration.\n" @@ -102,23 +102,15 @@ "Dans le cas contraire, vous définirez un modèle de présentation « local » " "dont vous pourrez définir l'ensemble de la configuration, mais ce modèle ne " "pourra pas être réutilisé en dehors des sous-niveaux qui pourront en " -"hériter...\n" -"ATTENTION : si vous choisissez d'hériter du modèle du parent, les " -"paramétrages spécifiques réalisés ici ne seront pas/plus pris en compte !" +"hériter..." -#: src/pyams_portal/zmi/page.py:219 +#: src/pyams_portal/zmi/page.py:169 msgid "Template properties" msgstr "Configuration du modèle" -#: src/pyams_portal/zmi/page.py:97 src/pyams_portal/zmi/page.py:161 -msgid "Use shared template" -msgstr "Utiliser un modèle de présentation partagé" - -#: src/pyams_portal/zmi/page.py:114 src/pyams_portal/zmi/page.py:189 -msgid "You must choose to use a local template or select a shared one!" -msgstr "" -"Vous devez choisir un modèle de présentation partagé lorsque vous " -"n'appliquez pas de modèle local !" +#: src/pyams_portal/zmi/page.py:139 +msgid "You must select which shared template to use!" +msgstr "Vous devez sélectionner le modèle de présentation partagé à utiliser !" #: src/pyams_portal/zmi/template.py:132 msgid "Add template" @@ -269,6 +261,18 @@ msgid "Tab label" msgstr "Libellé de l'onglet" +#: src/pyams_portal/zmi/templates/template-properties.pt:59 +msgid "Use shared template" +msgstr "Utiliser un modèle de présentation partagé" + +#: src/pyams_portal/zmi/templates/template-properties.pt:65 +msgid "Selected template" +msgstr "Modèle sélectionné" + +#: src/pyams_portal/zmi/templates/template-properties.pt:79 +msgid "Use custom local template" +msgstr "Utiliser un modèle de présentation spécifique (mode « local »)" + #: src/pyams_portal/zmi/templates/layout.pt:24 msgid "Add row
Drag and drop button to page template to position new row" msgstr "" @@ -566,6 +570,14 @@ msgid "Template used for this page" msgstr "Modèle de présentation utilisé pour cette page" +#~ msgid "Override parent template" +#~ msgstr "Ne pas hériter du modèle de présentation du parent" + +#~ msgid "You must choose to use a local template or select a shared one!" +#~ msgstr "" +#~ "Vous devez choisir un modèle de présentation partagé lorsque vous " +#~ "n'appliquez pas de modèle local !" + #~ msgid "Override parent or template settings" #~ msgstr "Remplacer le paramétrage du parent ou du modèle" diff -r 4ac5a1814dc0 -r 27cf196f066c src/pyams_portal/locales/pyams_portal.pot --- a/src/pyams_portal/locales/pyams_portal.pot Tue Sep 04 14:48:00 2018 +0200 +++ b/src/pyams_portal/locales/pyams_portal.pot Tue Sep 04 17:31:38 2018 +0200 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2018-09-04 14:12+0200\n" +"POT-Creation-Date: 2018-09-04 17:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" @@ -28,77 +28,73 @@ msgid "Portal templates manager" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:62 +#: ./src/pyams_portal/zmi/portlet.py:61 msgid "Edit portlet settings" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:108 +#: ./src/pyams_portal/zmi/portlet.py:107 msgid "" "WARNING: Portlet properties are saved automatically when changing inherit " "mode!!" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:118 +#: ./src/pyams_portal/zmi/portlet.py:117 msgid "Main properties" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:176 +#: ./src/pyams_portal/zmi/portlet.py:175 #: ./src/pyams_portal/zmi/templates/renderer-input.pt:4 msgid "Edit renderer properties" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:83 ./src/pyams_portal/zmi/portlet.py:89 +#: ./src/pyams_portal/zmi/portlet.py:82 ./src/pyams_portal/zmi/portlet.py:88 msgid "Override template settings" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:87 +#: ./src/pyams_portal/zmi/portlet.py:86 msgid "Override parent settings" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:57 +#: ./src/pyams_portal/zmi/portlet.py:56 #, python-format msgid "Local portal template - {0}" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:59 +#: ./src/pyams_portal/zmi/portlet.py:58 #, python-format msgid "« {0} » portal template - {1}" msgstr "" -#: ./src/pyams_portal/zmi/portlet.py:156 +#: ./src/pyams_portal/zmi/portlet.py:155 msgid "" "You changed renderer selection. Don't omit to update new renderer " "properties..." msgstr "" -#: ./src/pyams_portal/zmi/page.py:66 +#: ./src/pyams_portal/zmi/page.py:73 msgid "Presentation" msgstr "" -#: ./src/pyams_portal/zmi/page.py:129 +#: ./src/pyams_portal/zmi/page.py:95 msgid "Edit template configuration" msgstr "" -#: ./src/pyams_portal/zmi/page.py:130 -msgid "Override parent template" +#: ./src/pyams_portal/zmi/page.py:96 +msgid "Inherit parent template" msgstr "" -#: ./src/pyams_portal/zmi/page.py:203 +#: ./src/pyams_portal/zmi/page.py:153 msgid "" "If you choose a shared template, you can only adjust settings of each portlet individually but can't change portlets list or page configuration.\n" "If you use a local template, you can define a whole custom configuration but the template definition can't be reused anywhere..." msgstr "" -#: ./src/pyams_portal/zmi/page.py:219 +#: ./src/pyams_portal/zmi/page.py:169 msgid "Template properties" msgstr "" -#: ./src/pyams_portal/zmi/page.py:97 ./src/pyams_portal/zmi/page.py:161 -msgid "Use shared template" -msgstr "" - -#: ./src/pyams_portal/zmi/page.py:114 ./src/pyams_portal/zmi/page.py:189 -msgid "You must choose to use a local template or select a shared one!" +#: ./src/pyams_portal/zmi/page.py:139 +msgid "You must select which shared template to use!" msgstr "" #: ./src/pyams_portal/zmi/template.py:132 @@ -249,6 +245,18 @@ msgid "Tab label" msgstr "" +#: ./src/pyams_portal/zmi/templates/template-properties.pt:59 +msgid "Use shared template" +msgstr "" + +#: ./src/pyams_portal/zmi/templates/template-properties.pt:65 +msgid "Selected template" +msgstr "" + +#: ./src/pyams_portal/zmi/templates/template-properties.pt:79 +msgid "Use custom local template" +msgstr "" + #: ./src/pyams_portal/zmi/templates/layout.pt:24 msgid "Add row
Drag and drop button to page template to position new row" msgstr "" diff -r 4ac5a1814dc0 -r 27cf196f066c src/pyams_portal/zmi/page.py --- a/src/pyams_portal/zmi/page.py Tue Sep 04 14:48:00 2018 +0200 +++ b/src/pyams_portal/zmi/page.py Tue Sep 04 17:31:38 2018 +0200 @@ -9,6 +9,7 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # +from collections import OrderedDict __docformat__ = 'restructuredtext' @@ -16,7 +17,7 @@ # import standard library # import interfaces -from pyams_form.interfaces.form import IWidgetForm, IFormHelp, IInnerSubForm +from pyams_form.interfaces.form import IWidgetForm, IFormHelp from pyams_portal.interfaces import IPortalContext, IPortalPage, IPortalTemplateConfiguration, \ MANAGE_TEMPLATE_PERMISSION from pyams_portal.zmi.interfaces import IPortalContextTemplatePropertiesMenu @@ -29,23 +30,22 @@ # import packages from pyams_form.form import ajax_config -from pyams_form.group import NamedWidgetsGroup, FormWidgetsGroup from pyams_form.help import FormHelp from pyams_pagelet.pagelet import pagelet_config from pyams_portal.zmi.layout import PortalTemplateLayoutView, PortalTemplatePortletEditForm, \ PortalTemplatePortletAJAXEditForm from pyams_portal.zmi.template import PortalTemplateHeaderAdapter from pyams_skin.viewlet.menu import MenuItem +from pyams_template.template import template_config from pyams_utils.adapter import adapter_config from pyams_utils.url import absolute_url from pyams_viewlet.manager import viewletmanager_config from pyams_viewlet.viewlet import viewlet_config -from pyams_zmi.form import AdminEditForm, InnerAdminEditForm +from pyams_zmi.form import AdminEditForm from pyams_zmi.zmi.site import PropertiesEditFormHeaderAdapter from pyramid.events import subscriber from pyramid.view import view_config from z3c.form import field -from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget from zope.interface import implementer, Interface, Invalid from pyams_portal import _ @@ -68,55 +68,14 @@ url = '#template-properties.html' -class InheritedTemplateWidgetsGroup(FormWidgetsGroup): - """Inherit template widgets groups""" - - -@adapter_config(context=(IPortalContext, IPyAMSLayer, InheritedTemplateWidgetsGroup), provides=IInnerSubForm) -class InheritedPortalContextTemplatePropertiesEditForm(InnerAdminEditForm): - """Inherited portal context template properties""" - - def __new__(cls, context, request, group): - if not group.form.getContent().can_inherit: - return None - return InnerAdminEditForm.__new__(cls) - - legend = None - - fields = field.Fields(IPortalPage).select('use_shared_template', 'shared_template') - fields['use_shared_template'].widgetFactory = SingleCheckBoxFieldWidget - - edit_permission = MANAGE_TEMPLATE_PERMISSION - - def getContent(self): - return IPortalPage(self.context) - - def updateGroups(self): - self.add_group(NamedWidgetsGroup(self, 'inherited_template_properties', self.widgets, - ('use_shared_template', 'shared_template',), - legend=_("Use shared template"), - css_class='inner', - switch=True, - checkbox_switch=True, - checkbox_field=IPortalPage['use_shared_template'])) - super(InheritedPortalContextTemplatePropertiesEditForm, self).updateGroups() - - -@subscriber(IDataExtractedEvent, form_selector=InheritedPortalContextTemplatePropertiesEditForm) -def handle_inherited_template_proterties_extract_event(event): - """Handle template properties extract event""" - form = event.form - parent = form.parent_form # parent group! - form_data, form_errors = parent.form.extractData() - if form_data.get('override_parent'): - data = event.data - if data.get('use_shared_template') and not data.get('shared_template'): - parent.form.widgets.errors += (Invalid(_("You must choose to use a local template or select a shared " - "one!")),) +TEMPLATE_INHERIT_MODE = 'inherit' +TEMPLATE_SHARED_MODE = 'shared' +TEMPLATE_LOCAL_MODE = 'local' @pagelet_config(name='template-properties.html', context=IPortalContext, layer=IPyAMSLayer, permission=MANAGE_TEMPLATE_PERMISSION) +@template_config(template='templates/template-properties.pt', layer=IPyAMSLayer) @ajax_config(name='template-properties.json', context=IPortalContext, layer=IPyAMSLayer) @implementer(IWidgetForm, IInnerPage) class PortalContextTemplatePropertiesEditForm(AdminEditForm): @@ -127,44 +86,28 @@ return self.context.title legend = _("Edit template configuration") - override_legend = _("Override parent template") + inherit_legend = _("Inherit parent template") - @property - def fields(self): - if self.getContent().can_inherit: - fields = field.Fields(IPortalPage).select('override_parent') - fields['override_parent'].widgetFactory = SingleCheckBoxFieldWidget - else: - fields = field.Fields(IPortalPage).select('use_shared_template', 'shared_template') - fields['use_shared_template'].widgetFactory = SingleCheckBoxFieldWidget - return fields + fields = field.Fields(IPortalPage).select('shared_template') edit_permission = MANAGE_TEMPLATE_PERMISSION def getContent(self): return IPortalPage(self.context) - def updateGroups(self): - if self.getContent().can_inherit: - group = NamedWidgetsGroup(self, 'template_properties', self.widgets, - ('override_parent',), - legend=self.override_legend, - css_class='inner', - switch=True, - checkbox_switch=True, - checkbox_mode='disable', - checkbox_field=IPortalPage['override_parent'], - factory=InheritedTemplateWidgetsGroup) + def update_content(self, content, data): + data = data.get(self, data) + template_mode = self.request.params.get('template_mode') + if template_mode == TEMPLATE_INHERIT_MODE: + content.inherit_parent = True else: - group = NamedWidgetsGroup(self, 'template_properties', self.widgets, - ('use_shared_template', 'shared_template',), - legend=_("Use shared template"), - css_class='inner', - switch=True, - checkbox_switch=True, - checkbox_field=IPortalPage['use_shared_template']) - self.add_group(group) - super(PortalContextTemplatePropertiesEditForm, self).updateGroups() + content.inherit_parent = False + if template_mode == TEMPLATE_SHARED_MODE: + content.shared_template = data.get('shared_template') + content.use_local_template = False + elif template_mode == TEMPLATE_LOCAL_MODE: + content.use_local_template = True + return {IPortalPage: ('inherit_parent', 'use_local_template', 'shared_template')} def get_ajax_output(self, changes): output = super(self.__class__, self).get_ajax_output(changes) @@ -180,13 +123,13 @@ @subscriber(IDataExtractedEvent, form_selector=PortalContextTemplatePropertiesEditForm) -def handle_template_proterties_extract_event(event): +def handle_template_properties_extract_event(event): """Handle template properties extract event""" form = event.form if not form.getContent().can_inherit: data = event.data - if data.get('use_shared_template') and not data.get('shared_template'): - form.widgets.errors += (Invalid(_("You must choose to use a local template or select a shared one!")),) + if (form.request.params.get('template_mode') == TEMPLATE_SHARED_MODE) and not data.get('shared_template'): + form.widgets.errors += (Invalid(_("You must select which shared template to use!")),) @adapter_config(context=(Interface, IPyAMSLayer, PortalContextTemplatePropertiesEditForm), provides=IPageHeader) @@ -208,7 +151,7 @@ # -# +# Portal context template configuration # @viewlet_config(name='template-config.menu', context=IPortalContext, layer=IAdminLayer, diff -r 4ac5a1814dc0 -r 27cf196f066c src/pyams_portal/zmi/templates/template-properties.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_portal/zmi/templates/template-properties.pt Tue Sep 04 17:31:38 2018 +0200 @@ -0,0 +1,92 @@ +
+
+ + +

+ + +
+
+
Form prefix
+ +
+ +
+ +
+
+
Form suffix
+
+