Added default renderer for location map paragraph
authorThierry Florac <thierry.florac@onf.fr>
Wed, 18 Jul 2018 15:51:05 +0200
changeset 102 9821ede236b1
parent 101 9c1189405f90
child 103 c1cef6215051
child 105 9e70ec7ccaa8
Added default renderer for location map paragraph
src/pyams_default_theme/component/paragraph/interfaces/map.py
src/pyams_default_theme/component/paragraph/map.py
src/pyams_default_theme/component/paragraph/templates/map-default.pt
src/pyams_default_theme/component/paragraph/zmi/__init__.py
src/pyams_default_theme/component/paragraph/zmi/map.py
src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.mo
src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po
src/pyams_default_theme/locales/pyams_default_theme.pot
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/interfaces/map.py	Wed Jul 18 15:51:05 2018 +0200
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# 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")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/map.py	Wed Jul 18 15:51:05 2018 +0200
@@ -0,0 +1,99 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# 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', )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/zmi/__init__.py	Wed Jul 18 15:51:05 2018 +0200
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/zmi/map.py	Wed Jul 18 15:51:05 2018 +0200
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# 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)
Binary file src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.mo has changed
--- a/src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po	Wed Jul 18 09:23:18 2018 +0200
+++ b/src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po	Wed Jul 18 15:51:05 2018 +0200
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2018-07-03 09:32+0200\n"
+"POT-Creation-Date: 2018-07-18 14:48+0200\n"
 "PO-Revision-Date: 2017-06-07 12:41+0200\n"
 "Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
 "Language-Team: French\n"
@@ -24,11 +24,11 @@
 msgid "Default gallery renderer"
 msgstr "Par défaut"
 
-#: src/pyams_default_theme/component/keynumber/portlet/__init__.py:37
+#: src/pyams_default_theme/component/keynumber/portlet/__init__.py:55
 msgid "Horizontal list with carousel"
 msgstr "Liste horizontale (par défaut)"
 
-#: src/pyams_default_theme/component/keynumber/portlet/__init__.py:46
+#: src/pyams_default_theme/component/keynumber/portlet/__init__.py:64
 msgid "Vertical list"
 msgstr "Liste verticale"
 
@@ -58,6 +58,10 @@
 msgid "Default key points renderer"
 msgstr "Par défaut"
 
+#: src/pyams_default_theme/component/paragraph/map.py:95
+msgid "Default map renderer"
+msgstr "Par défaut"
+
 #: src/pyams_default_theme/component/paragraph/video.py:40
 #: src/pyams_default_theme/component/video/__init__.py:41
 msgid "Default video renderer"
@@ -97,6 +101,18 @@
 msgid "Default header renderer"
 msgstr "Par défaut"
 
+#: src/pyams_default_theme/component/paragraph/zmi/map.py:62
+msgid "Don't use default map configuration"
+msgstr "Ne pas utiliser la configuration de carte par défaut"
+
+#: src/pyams_default_theme/component/paragraph/interfaces/map.py:34
+msgid "Don't use default configuration?"
+msgstr "Ne pas utiliser la configuration par défaut ?"
+
+#: src/pyams_default_theme/component/paragraph/interfaces/map.py:38
+msgid "Use default configuration?"
+msgstr "Utiliser la configuration par défaut ?"
+
 #: src/pyams_default_theme/component/paragraph/interfaces/frame.py:29
 #: src/pyams_default_theme/component/paragraph/interfaces/verbatim.py:29
 #: src/pyams_default_theme/component/paragraph/interfaces/contact.py:29
@@ -200,9 +216,9 @@
 "ATTENTION : la sélection des éléments affichés dans cet aperçu ne tient pas "
 "compte du contexte éventuellement paramétré dans la vue"
 
-#: src/pyams_default_theme/shared/view/portlet/__init__.py:37
-msgid "Simple list view"
-msgstr "Liste simple"
+#: src/pyams_default_theme/shared/view/portlet/__init__.py:38
+msgid "Simple vertical view"
+msgstr "Liste verticale simple"
 
 #: src/pyams_default_theme/shared/imagemap/__init__.py:58
 msgid "Default imagemap renderer"
@@ -216,6 +232,10 @@
 msgid "Default logos renderer"
 msgstr "Par défaut"
 
+#: src/pyams_default_theme/viewlet/logo/templates/logo.pt:5
+msgid "Back home"
+msgstr "Revenir à l'accueil"
+
 #: src/pyams_default_theme/features/menu/portlet/navigation/__init__.py:49
 msgid "Horizontal list with vertical illustrations"
 msgstr "Liste horizontale avec illustrations verticales (par défaut)"
@@ -248,6 +268,22 @@
 msgid "Label associated with second level options menu"
 msgstr "Libellé associé au second niveau de sélection"
 
+#: src/pyams_default_theme/features/footer/interfaces.py:31
+msgid "Copyright"
+msgstr "Copyright"
+
+#: src/pyams_default_theme/features/footer/interfaces.py:32
+msgid "Copyright mention displayed in page footer"
+msgstr "Mention affichée dans le pied de page"
+
+#: src/pyams_default_theme/features/footer/zmi/__init__.py:64
+msgid "Footer links"
+msgstr "Liens du pied de page"
+
+#: src/pyams_default_theme/features/footer/skin/__init__.py:50
+msgid "PyAMS simple footer with links"
+msgstr "PyAMS: pied de page simple avec liens"
+
 #: src/pyams_default_theme/features/header/interfaces.py:31
 msgid "Banner image"
 msgstr "Bandeau"
@@ -268,7 +304,7 @@
 msgid "Top tabs"
 msgstr "Onglets de navigation"
 
-#: src/pyams_default_theme/features/header/skin/__init__.py:48
+#: src/pyams_default_theme/features/header/skin/__init__.py:52
 msgid "PyAMS simple header with banner and tabs"
 msgstr "PyAMS: en-tête simple avec bandeau et onglets de navigation"
 
--- a/src/pyams_default_theme/locales/pyams_default_theme.pot	Wed Jul 18 09:23:18 2018 +0200
+++ b/src/pyams_default_theme/locales/pyams_default_theme.pot	Wed Jul 18 15:51:05 2018 +0200
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2018-07-03 09:32+0200\n"
+"POT-Creation-Date: 2018-07-18 14:48+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"
@@ -24,11 +24,11 @@
 msgid "Default gallery renderer"
 msgstr ""
 
-#: ./src/pyams_default_theme/component/keynumber/portlet/__init__.py:37
+#: ./src/pyams_default_theme/component/keynumber/portlet/__init__.py:55
 msgid "Horizontal list with carousel"
 msgstr ""
 
-#: ./src/pyams_default_theme/component/keynumber/portlet/__init__.py:46
+#: ./src/pyams_default_theme/component/keynumber/portlet/__init__.py:64
 msgid "Vertical list"
 msgstr ""
 
@@ -56,6 +56,10 @@
 msgid "Default key points renderer"
 msgstr ""
 
+#: ./src/pyams_default_theme/component/paragraph/map.py:95
+msgid "Default map renderer"
+msgstr ""
+
 #: ./src/pyams_default_theme/component/paragraph/video.py:40
 #: ./src/pyams_default_theme/component/video/__init__.py:41
 msgid "Default video renderer"
@@ -95,6 +99,18 @@
 msgid "Default header renderer"
 msgstr ""
 
+#: ./src/pyams_default_theme/component/paragraph/zmi/map.py:62
+msgid "Don't use default map configuration"
+msgstr ""
+
+#: ./src/pyams_default_theme/component/paragraph/interfaces/map.py:34
+msgid "Don't use default configuration?"
+msgstr ""
+
+#: ./src/pyams_default_theme/component/paragraph/interfaces/map.py:38
+msgid "Use default configuration?"
+msgstr ""
+
 #: ./src/pyams_default_theme/component/paragraph/interfaces/frame.py:29
 #: ./src/pyams_default_theme/component/paragraph/interfaces/verbatim.py:29
 #: ./src/pyams_default_theme/component/paragraph/interfaces/contact.py:29
@@ -183,8 +199,8 @@
 msgid "WARNING: items displayed in this preview are out of context!!"
 msgstr ""
 
-#: ./src/pyams_default_theme/shared/view/portlet/__init__.py:37
-msgid "Simple list view"
+#: ./src/pyams_default_theme/shared/view/portlet/__init__.py:38
+msgid "Simple vertical view"
 msgstr ""
 
 #: ./src/pyams_default_theme/shared/imagemap/__init__.py:58
@@ -199,6 +215,10 @@
 msgid "Default logos renderer"
 msgstr ""
 
+#: ./src/pyams_default_theme/viewlet/logo/templates/logo.pt:5
+msgid "Back home"
+msgstr ""
+
 #: ./src/pyams_default_theme/features/menu/portlet/navigation/__init__.py:49
 msgid "Horizontal list with vertical illustrations"
 msgstr ""
@@ -231,6 +251,22 @@
 msgid "Label associated with second level options menu"
 msgstr ""
 
+#: ./src/pyams_default_theme/features/footer/interfaces.py:31
+msgid "Copyright"
+msgstr ""
+
+#: ./src/pyams_default_theme/features/footer/interfaces.py:32
+msgid "Copyright mention displayed in page footer"
+msgstr ""
+
+#: ./src/pyams_default_theme/features/footer/zmi/__init__.py:64
+msgid "Footer links"
+msgstr ""
+
+#: ./src/pyams_default_theme/features/footer/skin/__init__.py:50
+msgid "PyAMS simple footer with links"
+msgstr ""
+
 #: ./src/pyams_default_theme/features/header/interfaces.py:31
 msgid "Banner image"
 msgstr ""
@@ -251,6 +287,6 @@
 msgid "Top tabs"
 msgstr ""
 
-#: ./src/pyams_default_theme/features/header/skin/__init__.py:48
+#: ./src/pyams_default_theme/features/header/skin/__init__.py:52
 msgid "PyAMS simple header with banner and tabs"
 msgstr ""