# HG changeset patch # User Damien Correia # Date 1531932614 -7200 # Node ID c1cef6215051ce1a0b06218e75703383d4200c8c # Parent 29e43fc3a6a0a51b4cedc2a6d53b2d373263fe27# Parent 9821ede236b11ff7a36ce8941530394af737c451 Merge default diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/component/keynumber/portlet/__init__.py --- a/src/pyams_default_theme/component/keynumber/portlet/__init__.py Tue Jul 10 12:20:13 2018 +0200 +++ b/src/pyams_default_theme/component/keynumber/portlet/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -32,7 +32,7 @@ from pyams_default_theme import _ -class KeyNumberPortletDefaultRenderer(PortletRenderer): +class KeyNumberPortletBaseRenderer(PortletRenderer): """Key numbers portlet default renderer""" def get_link_info(cls, link): @@ -49,7 +49,7 @@ @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IKeyNumberPortletSettings), provides=IPortletRenderer) @template_config(template='templates/horizontal-render.pt', layer=IPyAMSLayer) -class KeyNumberPortletHorizontalRenderer(KeyNumberPortletDefaultRenderer): +class KeyNumberPortletHorizontalRenderer(KeyNumberPortletBaseRenderer): """Key numbers portlet horizontal renderer""" label = _("Horizontal list with carousel") @@ -58,7 +58,7 @@ @adapter_config(name='vertical', context=(IPortalContext, IPyAMSLayer, Interface, IKeyNumberPortletSettings), provides=IPortletRenderer) @template_config(template='templates/vertical-render.pt', layer=IPyAMSLayer) -class KeyNumberPortletVerticalRenderer(KeyNumberPortletDefaultRenderer): +class KeyNumberPortletVerticalRenderer(KeyNumberPortletBaseRenderer): """Key numbers portlet vertical renderer""" label = _("Vertical list") diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/component/paragraph/interfaces/map.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/paragraph/interfaces/map.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,42 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +from pyams_content.component.paragraph.interfaces.map import have_gis +if have_gis: + + # import standard library + + # import interfaces + from pyams_gis.interfaces.configuration import IMapConfiguration + + # import packages + from zope.interface import Attribute + from zope.schema import Bool + + from pyams_default_theme import _ + + + class IMapParagraphDefaultRendererSettings(IMapConfiguration): + """Map paragraph default renderer settings interface""" + + no_use_default_map_configuration = Bool(title=_("Don't use default configuration?"), + required=True, + default=False) + + use_default_map_configuration = Bool(title=_("Use default configuration?"), + required=True, + default=True) + + configuration = Attribute("Map configuration") diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/component/paragraph/map.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/paragraph/map.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,99 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +from pyams_content.component.paragraph.interfaces.map import have_gis, IMapParagraph +if have_gis: + + # import standard library + + # import interfaces + from pyams_content.features.renderer.interfaces import IContentRenderer + from pyams_default_theme.component.paragraph.interfaces.map import IMapParagraphDefaultRendererSettings + from pyams_gis.interfaces.configuration import IMapConfiguration + from pyams_gis.interfaces.utility import IMapManager + from pyams_skin.layer import IPyAMSLayer + + # import packages + from pyams_content.features.renderer.skin import BaseContentRenderer + from pyams_gis.configuration import MapConfiguration + from pyams_template.template import template_config + from pyams_utils.adapter import adapter_config, get_annotation_adapter + from pyams_utils.registry import get_utility + from zope.interface import implementer + from zope.schema.fieldproperty import FieldProperty + + from pyams_default_theme import _ + + + # + # Map paragraph default renderer settings + # + + MAP_DEFAULT_RENDERER_SETTINGS_KEY = 'pyams_content.map.renderer:default' + + + @implementer(IMapParagraphDefaultRendererSettings) + class MapParagraphDefaultRendererSettings(MapConfiguration): + """Map paragraph default renderer settings""" + + _use_default_map_configuration = FieldProperty(IMapParagraphDefaultRendererSettings[ + 'use_default_map_configuration']) + + @property + def use_default_map_configuration(self): + return self._use_default_map_configuration + + @use_default_map_configuration.setter + def use_default_map_configuration(self, value): + self._use_default_map_configuration = value + + @property + def no_use_default_map_configuration(self): + return not bool(self.use_default_map_configuration) + + @no_use_default_map_configuration.setter + def no_use_default_map_configuration(self, value): + self.use_default_map_configuration = not bool(value) + + @property + def configuration(self): + if self.use_default_map_configuration: + manager = get_utility(IMapManager) + return IMapConfiguration(manager) + else: + return self + + + @adapter_config(context=IMapParagraph, provides=IMapParagraphDefaultRendererSettings) + def map_paragraph_default_renderer_settings_factory(context): + """Map paragraph default renderer settings factory""" + return get_annotation_adapter(context, MAP_DEFAULT_RENDERER_SETTINGS_KEY, + MapParagraphDefaultRendererSettings) + + + # + # Map paragraph default renderer + # + + @adapter_config(name='default', context=(IMapParagraph, IPyAMSLayer), provides=IContentRenderer) + @template_config(template='templates/map-default.pt', layer=IPyAMSLayer) + class MapParagraphDefaultRenderer(BaseContentRenderer): + """Map paragraph default renderer""" + + label = _("Default map renderer") + + settings_interface = IMapParagraphDefaultRendererSettings + + i18n_context_attrs = ('title', ) diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/component/paragraph/templates/map-default.pt diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/component/paragraph/zmi/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/paragraph/zmi/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,20 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces + +# import packages diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/component/paragraph/zmi/map.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/paragraph/zmi/map.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,67 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +from pyams_content.component.paragraph.interfaces.map import have_gis +if have_gis: + + # import standard library + + # import interfaces + from pyams_default_theme.component.paragraph.interfaces.map import IMapParagraphDefaultRendererSettings + from pyams_form.interfaces.form import IFormManager + from pyams_skin.layer import IPyAMSLayer + + # import packages + from pyams_content.features.renderer.zmi import RendererPropertiesEditForm + from pyams_form.group import NamedWidgetsGroup + from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter + from pyams_zmi.form import AdminDialogEditForm + from z3c.form import field + from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget + + from pyams_default_theme import _ + + + @adapter_config(context=(IMapParagraphDefaultRendererSettings, IPyAMSLayer, RendererPropertiesEditForm), + provides=IFormManager) + class MapParagraphDefaultRendererSettingsFormManager(ContextRequestViewAdapter): + """Map paragraph default renderer settings form manager""" + + def getFields(self): + fields = field.Fields(IMapParagraphDefaultRendererSettings).omit('use_default_map_configuration') + fields['no_use_default_map_configuration'].widgetFactory = SingleCheckBoxFieldWidget + return fields + + def update(self): + view = self.view + view.dialog_class = 'modal-large' + AdminDialogEditForm.update(view) + + def updateWidgets(self, prefix=None): + AdminDialogEditForm.updateWidgets(self.view, prefix) + + def updateActions(self): + AdminDialogEditForm.updateActions(self.view) + + def updateGroups(self): + view = self.view + view.add_group(NamedWidgetsGroup(view, 'configuration', view.widgets, + view.fields.keys(), + legend=_("Don't use default map configuration"), + css_class='inner', + switch=True, + checkbox_switch=True, + checkbox_field=IMapParagraphDefaultRendererSettings['no_use_default_map_configuration'])) + AdminDialogEditForm.updateGroups(view) diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/footer/__init__.py --- a/src/pyams_default_theme/features/footer/__init__.py Tue Jul 10 12:20:13 2018 +0200 +++ b/src/pyams_default_theme/features/footer/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -16,12 +16,22 @@ # import standard library # import interfaces +from pyams_content.component.association.interfaces import ASSOCIATION_CONTAINER_KEY from pyams_content.features.footer.interfaces import IFooterTarget, IFooterSettings +from pyams_content.features.menu.interfaces import IMenuLinksContainerTarget, IMenuLinksContainer +from pyams_default_theme.features.footer.interfaces import ISimpleFooterRendererSettings, ISimpleFooterLinksMenu from pyams_default_theme.layer import IPyAMSDefaultLayer +from zope.location.interfaces import ISublocations # import packages +from persistent import Persistent +from pyams_content.features.menu import Menu +from pyams_utils.adapter import get_annotation_adapter, adapter_config, ContextAdapter from pyams_utils.traversing import get_parent from pyams_viewlet.viewlet import contentprovider_config, ViewContentProvider +from zope.interface import implementer +from zope.location import Location +from zope.schema.fieldproperty import FieldProperty @contentprovider_config(name='pyams.footer', layer=IPyAMSDefaultLayer) @@ -29,11 +39,16 @@ """Footer content provider""" footer = None + renderer = None def update(self): parent = get_parent(self.context, IFooterTarget) if parent is not None: - self.footer = IFooterSettings(parent, None) + footer = self.footer = IFooterSettings(parent, None) + if footer is not None: + renderer = self.renderer = footer.get_renderer(self.request) + if renderer is not None: + renderer.update() def render(self): if self.footer is None: @@ -42,3 +57,36 @@ if renderer is None: return '' return renderer.render() + + +# +# Simple footer renderer settings +# + +SIMPLE_FOOTER_LINKS_KEY = '{0}::links'.format(ASSOCIATION_CONTAINER_KEY) + + +@implementer(ISimpleFooterRendererSettings, IMenuLinksContainerTarget) +class SimpleFooterRendererSettings(Persistent, Location): + """Simple footer renderer settings""" + + copyright = FieldProperty(ISimpleFooterRendererSettings['copyright']) + + @property + def links(self): + return get_annotation_adapter(self, SIMPLE_FOOTER_LINKS_KEY, Menu, + markers=ISimpleFooterLinksMenu, name='++ass++links') + + +@adapter_config(name='links', context=ISimpleFooterRendererSettings, provides=IMenuLinksContainer) +def simple_footer_links_adapter(context): + """Simple footer links adapter""" + return context.links + + +@adapter_config(name='links', context=ISimpleFooterRendererSettings, provides=ISublocations) +class SimpleFooterRendererSettingsSublocations(ContextAdapter): + """Simple footer renderer settings sub-locations adapter""" + + def sublocations(self): + return self.context.links.values() diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/footer/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/footer/interfaces.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,39 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces +from pyams_content.features.footer.interfaces import IFooterRendererSettings + +# import packages +from zope.interface import Interface, Attribute +from zope.schema import TextLine + +from pyams_default_theme import _ + + +class ISimpleFooterRendererSettings(IFooterRendererSettings): + """Simple footer renderer settings""" + + copyright = TextLine(title=_("Copyright"), + description=_("Copyright mention displayed in page footer"), + required=False) + + links = Attribute("Footer links") + + +class ISimpleFooterLinksMenu(Interface): + """Simple footer links marker interface""" diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/footer/skin/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/footer/skin/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,64 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces +from pyams_content.component.association.interfaces import IAssociationInfo +from pyams_content.features.footer.interfaces import IFooterTarget, IFooterRenderer, IFooterSettings, \ + IFooterRendererSettings +from pyams_default_theme.features.footer.interfaces import ISimpleFooterRendererSettings +from pyams_skin.layer import IPyAMSLayer + +# import packages +from pyams_content.features.footer.skin import BaseFooterRenderer +from pyams_default_theme.features.footer import SimpleFooterRendererSettings +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config + +from pyams_default_theme import _ + + +SIMPLE_FOOTER_RENDERER_NAME = 'PyAMS simple header' + + +# +# Simple footer renderer +# + +@adapter_config(name=SIMPLE_FOOTER_RENDERER_NAME, context=(IFooterTarget, IPyAMSLayer), + provides=IFooterRenderer) +@adapter_config(name=SIMPLE_FOOTER_RENDERER_NAME, context=(IFooterSettings, IPyAMSLayer), + provides=IFooterRenderer) +@template_config(template='templates/simple-footer.pt', layer=IPyAMSLayer) +class SimpleFooterRenderer(BaseFooterRenderer): + """Simple footer renderer""" + + name = SIMPLE_FOOTER_RENDERER_NAME + label = _("PyAMS simple footer with links") + weight = 1 + + settings_key = 'PyAMS::simple' + settings_interface = ISimpleFooterRendererSettings + + @staticmethod + def get_link_info(link): + return IAssociationInfo(link) + + +@adapter_config(context=SimpleFooterRenderer, provides=IFooterRendererSettings) +def simple_footer_renderer_settings_factory(context): + """Simple footer renderer settings factory""" + return SimpleFooterRendererSettings() diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/footer/skin/templates/simple-footer.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/footer/skin/templates/simple-footer.pt Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,15 @@ + diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/footer/zmi/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/footer/zmi/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -0,0 +1,67 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces +from pyams_default_theme.features.footer.interfaces import ISimpleFooterRendererSettings, ISimpleFooterLinksMenu +from pyams_form.interfaces.form import IInnerSubForm +from pyams_portal.interfaces import MANAGE_TEMPLATE_PERMISSION +from pyams_skin.layer import IPyAMSLayer + +# import packages +from pyams_content.features.footer.zmi import FooterSettingsRendererSettingsEditForm +from pyams_content.features.menu.zmi import LinksTable, IMenuLinksView, MenuLinksView +from pyams_utils.adapter import adapter_config +from pyams_zmi.form import InnerAdminEditForm +from z3c.form import field + +from pyams_default_theme import _ + + +@adapter_config(name='simple-footer-properties', + context=(ISimpleFooterRendererSettings, IPyAMSLayer, FooterSettingsRendererSettingsEditForm), + provides=IInnerSubForm) +class SimpleFooterPropertiesEditForm(InnerAdminEditForm): + """Simple footer properties edit form""" + + legend = None + edit_permission = MANAGE_TEMPLATE_PERMISSION + weight = 1 + + fields = field.Fields(ISimpleFooterRendererSettings) + + +# +# Footer links table view +# + +class LinksAssociationsTable(LinksTable): + """Simple footer links associations table""" + + associations_name = 'links' + + +@adapter_config(name='simple-footer-links', + context=(ISimpleFooterRendererSettings, IPyAMSLayer, FooterSettingsRendererSettingsEditForm), + provides=IInnerSubForm) +@adapter_config(name='++ass++links', context=(ISimpleFooterLinksMenu, IPyAMSLayer), provides=IMenuLinksView) +class SimpleFooterTabsView(MenuLinksView): + """Simple footer links view""" + + title = _("Footer links") + + table_class = LinksAssociationsTable + weight = 10 diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/header/__init__.py --- a/src/pyams_default_theme/features/header/__init__.py Tue Jul 10 12:20:13 2018 +0200 +++ b/src/pyams_default_theme/features/header/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -31,7 +31,7 @@ from pyams_utils.traversing import get_parent from pyams_viewlet.viewlet import contentprovider_config, ViewContentProvider from zope.interface import implementer -from zope.location import Location, locate +from zope.location import Location @contentprovider_config(name='pyams.header', layer=IPyAMSDefaultLayer) diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/header/skin/__init__.py --- a/src/pyams_default_theme/features/header/skin/__init__.py Tue Jul 10 12:20:13 2018 +0200 +++ b/src/pyams_default_theme/features/header/skin/__init__.py Wed Jul 18 18:50:14 2018 +0200 @@ -40,8 +40,10 @@ # Simple header renderer # -@adapter_config(name=SIMPLE_HEADER_RENDERER_NAME, context=(IHeaderTarget, IPyAMSLayer), provides=IHeaderRenderer) -@adapter_config(name=SIMPLE_HEADER_RENDERER_NAME, context=(IHeaderSettings, IPyAMSLayer), provides=IHeaderRenderer) +@adapter_config(name=SIMPLE_HEADER_RENDERER_NAME, context=(IHeaderTarget, IPyAMSLayer), + provides=IHeaderRenderer) +@adapter_config(name=SIMPLE_HEADER_RENDERER_NAME, context=(IHeaderSettings, IPyAMSLayer), + provides=IHeaderRenderer) @template_config(template='templates/simple-header.pt', layer=IPyAMSLayer) class SimpleHeaderRenderer(BaseHeaderRenderer): """Simple header renderer""" diff -r 29e43fc3a6a0 -r c1cef6215051 src/pyams_default_theme/features/header/skin/templates/simple-header.pt --- a/src/pyams_default_theme/features/header/skin/templates/simple-header.pt Tue Jul 10 12:20:13 2018 +0200 +++ b/src/pyams_default_theme/features/header/skin/templates/simple-header.pt Wed Jul 18 18:50:14 2018 +0200 @@ -1,8 +1,8 @@
-