Binary file src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.mo has changed
--- 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 <tflorac@ulthar.net>\n"
"Language-Team: French <traduc@traduc.org>\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<br />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"
--- 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 <EMAIL@ADDRESS\n"
"Language-Team: LANGUAGE <LL@li.org>\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<br />Drag and drop button to page template to position new row"
msgstr ""
--- 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,
--- /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 @@
+<div class="ams-widget" i18n:domain="pyams_portal">
+ <header>
+ <span tal:condition="view.widget_icon_class | nothing"
+ class="widget-icon"><i tal:attributes="class view.widget_icon_class"></i>
+ </span>
+ <h2 tal:content="view.legend"></h2>
+ <tal:var content="structure provider:pyams.widget_title" />
+ <tal:var content="structure provider:pyams.toolbar" />
+ </header>
+ <div class="widget-body no-padding">
+ <div tal:define="prefix provider:form_prefix"
+ tal:replace="structure prefix">Form prefix</div>
+ <tal:var content="structure provider:form_help" />
+ <form method="post"
+ data-async
+ tal:attributes="id view.id;
+ name view.name;
+ action view.get_form_action();
+ method view.method;
+ enctype view.enctype;
+ acceptCharset view.acceptCharset;
+ accept view.accept;
+ autocomplete view.autocomplete;
+ class view.css_class;
+ data-ams-data tales:object_data(view);
+ data-ams-form-handler view.get_ajax_handler() | nothing;
+ data-ams-form-options view.get_form_options() | nothing;
+ data-ams-form-submit-target view.form_target | nothing;
+ data-ams-form-download-target view.download_target | nothing;
+ data-ams-warn-on-change view.warn_on_change;">
+ <div class="modal-viewport">
+ <fieldset class="padding-x-20"
+ tal:define="content view.getContent()">
+ <div class="widgets-prefix"
+ tal:omit-tag="getattr(view, 'hide_widgets_prefix_div', False)"
+ tal:define="prefix provider:widgets_prefix"
+ tal:condition="prefix"
+ tal:content="structure prefix">Widgets prefix</div>
+ <div class="clearfix"></div>
+ <div tal:condition="content.can_inherit">
+ <div class="form-group no-margin">
+ <label class="radio">
+ <input type="radio"
+ value="inherit"
+ id="inherit_template_mode"
+ name="template_mode"
+ checked="${'checked' if content.inherit_parent else None}" />
+ <i></i><span i18n:translate="">${view.inherit_legend}</span>
+ </label>
+ </div>
+ </div>
+ <div class="form-group no-margin">
+ <label class="radio">
+ <input type="radio"
+ value="shared"
+ id="shared_template_mode"
+ name="template_mode"
+ checked="${'checked' if content.use_shared_template else None}" />
+ <i></i><span i18n:translate="">Use shared template</span>
+ </label>
+ </div>
+ <div class="form-group">
+ <div class="required-field">
+ <div class="control-label col-md-2">
+ <span i18n:translate="">Selected template</span>
+ </div>
+ <div class="col-md-8">
+ <div class="input">${structure:view.widgets['shared_template'].render()}</div>
+ </div>
+ </div>
+ </div>
+ <div class="form-group no-margin">
+ <label class="radio">
+ <input type="radio"
+ value="local"
+ id="local_template_mode"
+ name="template_mode"
+ checked="${'checked' if content.use_local_template else None}" />
+ <i></i><span i18n:translate="">Use custom local template</span>
+ </label>
+ </div>
+ </fieldset>
+ </div>
+ <footer tal:condition="view.actions and (view.is_dialog or (view.mode == 'input'))">
+ <button tal:repeat="action view.actions.values()"
+ tal:replace="structure action.render()">Action</button>
+ </footer>
+ </form>
+ <div tal:define="prefix provider:form_suffix"
+ tal:replace="structure prefix">Form suffix</div>
+ </div>
+</div>