imio.smartweb.core 1.2.33__py3-none-any.whl → 1.2.37__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. imio/smartweb/core/browser/sitemap.py +52 -48
  2. imio/smartweb/core/browser/utils.py +1 -2
  3. imio/smartweb/core/contents/rest/utils.py +99 -0
  4. imio/smartweb/core/contents/sections/contact/utils.py +0 -4
  5. imio/smartweb/core/contents/sections/external_content/configure.zcml +29 -0
  6. imio/smartweb/core/contents/sections/external_content/view.pt +25 -7
  7. imio/smartweb/core/contents/sections/external_content/view_idelux_waste.pt +50 -0
  8. imio/smartweb/core/contents/sections/external_content/view_inbw_containers_affluence.pt +91 -0
  9. imio/smartweb/core/contents/sections/external_content/view_odwb_widget.pt +20 -0
  10. imio/smartweb/core/contents/sections/external_content/views.py +303 -124
  11. imio/smartweb/core/contents/sections/macros.pt +13 -9
  12. imio/smartweb/core/contents/sections/text/view.pt +1 -1
  13. imio/smartweb/core/interfaces.py +7 -0
  14. imio/smartweb/core/profiles/default/diff_tool.xml +8 -0
  15. imio/smartweb/core/profiles/default/metadata.xml +1 -1
  16. imio/smartweb/core/profiles/default/registry/plone.xml +21 -4
  17. imio/smartweb/core/profiles/default/repositorytool.xml +1 -0
  18. imio/smartweb/core/profiles/default/types/Collection.xml +13 -0
  19. imio/smartweb/core/profiles/default/types/File.xml +13 -0
  20. imio/smartweb/core/profiles/default/types/Image.xml +13 -0
  21. imio/smartweb/core/profiles/default/types/imio.smartweb.BlockLink.xml +5 -0
  22. imio/smartweb/core/profiles/default/types/imio.smartweb.CirkwiView.xml +1 -0
  23. imio/smartweb/core/profiles/default/types/imio.smartweb.DirectoryView.xml +1 -0
  24. imio/smartweb/core/profiles/default/types/imio.smartweb.EventsView.xml +1 -0
  25. imio/smartweb/core/profiles/default/types/imio.smartweb.Folder.xml +1 -0
  26. imio/smartweb/core/profiles/default/types/imio.smartweb.NewsView.xml +1 -0
  27. imio/smartweb/core/profiles/default/types/imio.smartweb.Page.xml +1 -0
  28. imio/smartweb/core/profiles/default/types/imio.smartweb.PortalPage.xml +1 -0
  29. imio/smartweb/core/profiles/default/types/imio.smartweb.Procedure.xml +1 -0
  30. imio/smartweb/core/profiles/default/types/imio.smartweb.SectionHTML.xml +0 -1
  31. imio/smartweb/core/profiles/validation/contentrules.xml +102 -0
  32. imio/smartweb/core/profiles.zcml +8 -0
  33. imio/smartweb/core/tests/test_section_external_content.py +23 -23
  34. imio/smartweb/core/tests/test_sections.py +21 -15
  35. imio/smartweb/core/tests/test_sitemap.py +41 -22
  36. imio/smartweb/core/upgrades/configure.zcml +54 -0
  37. imio/smartweb/core/upgrades/profiles/1052_to_1053/diff_tool.xml +8 -0
  38. imio/smartweb/core/upgrades/profiles/1052_to_1053/repositorytool.xml +9 -0
  39. imio/smartweb/core/upgrades/profiles/1052_to_1053/types/imio.smartweb.SectionHTML.xml +14 -0
  40. imio/smartweb/core/upgrades/profiles/1053_to_1054/registry.xml +39 -0
  41. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/Collection.xml +13 -0
  42. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/File.xml +13 -0
  43. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/Image.xml +13 -0
  44. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.BlockLink.xml +12 -0
  45. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.CirkwiView.xml +12 -0
  46. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.DirectoryView.xml +12 -0
  47. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.EventsView.xml +12 -0
  48. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Folder.xml +12 -0
  49. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.NewsView.xml +12 -0
  50. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Page.xml +12 -0
  51. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.PortalPage.xml +12 -0
  52. imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Procedure.xml +12 -0
  53. imio/smartweb/core/viewlets/configure.zcml +10 -0
  54. imio/smartweb/core/viewlets/external_content.py +13 -5
  55. imio/smartweb/core/viewlets/odwb_widget_header.pt +19 -0
  56. imio/smartweb/core/viewlets/ogptags.py +1 -2
  57. imio/smartweb/core/webcomponents/build/css/373.smartweb-webcomponents-compiled.css +1 -0
  58. imio/smartweb/core/webcomponents/build/css/486.smartweb-webcomponents-compiled.css +1 -0
  59. imio/smartweb/core/webcomponents/build/css/686.smartweb-webcomponents-compiled.css +1 -0
  60. imio/smartweb/core/webcomponents/build/css/919.smartweb-webcomponents-compiled.css +1 -0
  61. imio/smartweb/core/webcomponents/build/css/smartweb-webcomponents-compiled.css +1 -1
  62. imio/smartweb/core/webcomponents/build/js/209.smartweb-webcomponents-compiled.js +2 -0
  63. imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js +2 -0
  64. imio/smartweb/core/webcomponents/build/js/373.smartweb-webcomponents-compiled.js +1 -0
  65. imio/smartweb/core/webcomponents/build/js/486.smartweb-webcomponents-compiled.js +1 -0
  66. imio/smartweb/core/webcomponents/build/js/568.smartweb-webcomponents-compiled.js +2 -0
  67. imio/smartweb/core/webcomponents/build/js/568.smartweb-webcomponents-compiled.js.LICENSE.txt +14 -0
  68. imio/smartweb/core/webcomponents/build/js/674.smartweb-webcomponents-compiled.js +2 -0
  69. imio/smartweb/core/webcomponents/build/js/686.smartweb-webcomponents-compiled.js +1 -0
  70. imio/smartweb/core/webcomponents/build/js/799.smartweb-webcomponents-compiled.js +2 -0
  71. imio/smartweb/core/webcomponents/build/js/804.smartweb-webcomponents-compiled.js +1 -0
  72. imio/smartweb/core/webcomponents/build/js/919.smartweb-webcomponents-compiled.js +1 -0
  73. imio/smartweb/core/webcomponents/build/js/smartweb-webcomponents-compiled.js +1 -1
  74. imio/smartweb/core/webcomponents/src/utils/translation.js +2 -2
  75. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/METADATA +38 -1
  76. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/RECORD +86 -63
  77. imio/smartweb/core/webcomponents/build/css/323.smartweb-webcomponents-compiled.css +0 -1
  78. imio/smartweb/core/webcomponents/build/css/392.smartweb-webcomponents-compiled.css +0 -1
  79. imio/smartweb/core/webcomponents/build/css/528.smartweb-webcomponents-compiled.css +0 -1
  80. imio/smartweb/core/webcomponents/build/css/647.smartweb-webcomponents-compiled.css +0 -1
  81. imio/smartweb/core/webcomponents/build/js/143.smartweb-webcomponents-compiled.js +0 -2
  82. imio/smartweb/core/webcomponents/build/js/144.smartweb-webcomponents-compiled.js +0 -2
  83. imio/smartweb/core/webcomponents/build/js/323.smartweb-webcomponents-compiled.js +0 -1
  84. imio/smartweb/core/webcomponents/build/js/392.smartweb-webcomponents-compiled.js +0 -1
  85. imio/smartweb/core/webcomponents/build/js/493.smartweb-webcomponents-compiled.js +0 -2
  86. imio/smartweb/core/webcomponents/build/js/528.smartweb-webcomponents-compiled.js +0 -2
  87. imio/smartweb/core/webcomponents/build/js/528.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -1
  88. imio/smartweb/core/webcomponents/build/js/647.smartweb-webcomponents-compiled.js +0 -1
  89. imio/smartweb/core/webcomponents/build/js/729.smartweb-webcomponents-compiled.js +0 -2
  90. imio/smartweb/core/webcomponents/build/js/729.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -1
  91. imio/smartweb/core/webcomponents/build/js/9.smartweb-webcomponents-compiled.js +0 -2
  92. imio/smartweb/core/webcomponents/build/js/969.smartweb-webcomponents-compiled.js +0 -2
  93. imio/smartweb/core/webcomponents/build/js/969.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -642
  94. imio/smartweb/core/webcomponents/build/js/979.smartweb-webcomponents-compiled.js +0 -1
  95. /imio/smartweb/core/webcomponents/build/js/{9.smartweb-webcomponents-compiled.js.LICENSE.txt → 209.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
  96. /imio/smartweb/core/webcomponents/build/js/{143.smartweb-webcomponents-compiled.js.LICENSE.txt → 218.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
  97. /imio/smartweb/core/webcomponents/build/js/{493.smartweb-webcomponents-compiled.js.LICENSE.txt → 674.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
  98. /imio/smartweb/core/webcomponents/build/js/{144.smartweb-webcomponents-compiled.js.LICENSE.txt → 799.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
  99. /imio.smartweb.core-1.2.33-py3.10-nspkg.pth → /imio.smartweb.core-1.2.37-py3.10-nspkg.pth +0 -0
  100. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/LICENSE.GPL +0 -0
  101. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/LICENSE.rst +0 -0
  102. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/WHEEL +0 -0
  103. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/namespace_packages.txt +0 -0
  104. {imio.smartweb.core-1.2.33.dist-info → imio.smartweb.core-1.2.37.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,8 @@
2
2
 
3
3
  from embeddify import Embedder
4
4
  from embeddify import Plugin
5
+
6
+ from imio.smartweb.core.interfaces import IOdwbViewUtils
5
7
  from imio.smartweb.core.contents.sections.views import SectionView
6
8
  from imio.smartweb.core.interfaces import IArcgisViewUtils
7
9
  from imio.smartweb.locales import SmartwebMessageFactory as _
@@ -11,12 +13,22 @@ from plone.app.contenttypes.behaviors.leadimage import ILeadImage
11
13
  from Products.Five.browser import BrowserView
12
14
  from zope.i18n import translate
13
15
  from zope.interface import implementer
16
+ from zope.interface import Interface
17
+ from zope.publisher.interfaces.browser import IDefaultBrowserLayer
14
18
 
15
19
  import json
20
+ import logging
21
+ import requests
22
+
23
+ logger = logging.getLogger("imio.smartweb.core")
16
24
 
17
25
 
18
26
  class ExternalContentView(SectionView):
19
- def get_embed_external_content(self, width="100%", height=600):
27
+
28
+ plugin_config = {}
29
+
30
+ def __init__(self, context, request):
31
+ width = "100%"
20
32
  current_lang = api.portal.get_current_language()[:2]
21
33
  plugins = [
22
34
  EaglebePlugin(),
@@ -24,10 +36,13 @@ class ExternalContentView(SectionView):
24
36
  CognitoformPlugin(),
25
37
  ArcgisPlugin(),
26
38
  GiveADayPlugin(),
39
+ IdeluxWastePlugin(),
40
+ InbwContainersAffluencePlugin(),
41
+ OdwbWidgetPlugin(),
27
42
  UnknowServicePlugin(),
28
43
  ]
29
- extra_params = self.context.external_content_params
30
- plugin_config = {
44
+ extra_params = context.external_content_params
45
+ self.plugin_config = {
31
46
  "eaglebeplugin": {"width": width},
32
47
  "ellohaplugin": {
33
48
  "width": width,
@@ -41,16 +56,39 @@ class ExternalContentView(SectionView):
41
56
  },
42
57
  "arcgisplugin": {
43
58
  "width": width,
44
- "url": self.context.absolute_url(),
59
+ "url": context.absolute_url(),
45
60
  "current_lang": current_lang,
46
61
  "extra_params": extra_params,
47
62
  },
48
63
  "giveadayplugin": {},
64
+ "ideluxwasteplugin": {
65
+ "url": context.absolute_url(),
66
+ "extra_params": extra_params,
67
+ },
68
+ "inbwcontainersaffluenceplugin": {
69
+ "url": context.absolute_url(),
70
+ "extra_params": extra_params,
71
+ },
72
+ "odwbwidgetplugin": {
73
+ "url": context.absolute_url(),
74
+ "extra_params": extra_params,
75
+ },
49
76
  "unknowserviceplugin": {"width": width, "current_lang": current_lang},
50
77
  }
51
- embedder = Embedder(plugins=plugins, plugin_config=plugin_config)
52
- url = self.context.external_content_url
53
- return embedder(url, config={"width": width})
78
+ embedder = Embedder(plugins=plugins, plugin_config=self.plugin_config)
79
+ url = context.external_content_url
80
+ self.plugin = embedder(url, config={"width": width})
81
+ super(ExternalContentView, self).__init__(context, request)
82
+
83
+ @property
84
+ def contents(self):
85
+ return self.plugin.contents
86
+
87
+ def display_odwb_widget_viewlet(self):
88
+ return self.plugin.is_odwb_widget_plugins
89
+
90
+ def render_viewlet(self):
91
+ return self.index()
54
92
 
55
93
  def has_leadimage(self):
56
94
  if ILeadImage.providedBy(self.context) and getattr(
@@ -59,161 +97,279 @@ class ExternalContentView(SectionView):
59
97
  return True
60
98
  return False
61
99
 
100
+ def get_plugin(self):
101
+ return self.plugin
102
+
103
+ def which_plugin(self):
104
+ if IOdwbWidgetPlugin.providedBy(self.plugin):
105
+ return "odwbwidgetplugin"
106
+ elif IIdeluxWastePlugin.providedBy(self.plugin):
107
+ return "ideluxwasteplugin"
108
+ elif IInbwContainersAffluencePlugin.providedBy(self.plugin):
109
+ return "inbwcontainersaffluenceplugin"
110
+ else:
111
+ return None
112
+
62
113
  def image(self):
63
114
  return f"{self.context.absolute_url()}/@@download/image"
64
115
 
65
116
 
66
- class EaglebePlugin(Plugin):
117
+ class BasePlugin(Plugin):
118
+ """ """
119
+
120
+ is_odwb_widget_plugins = False
121
+
122
+ @property
123
+ def contents(self):
124
+ return ""
125
+
126
+
127
+ class EaglebePlugin(BasePlugin):
67
128
  def __call__(self, parts, config={}):
129
+ self.parts = parts
130
+ self.config = config
68
131
  if "app.eaglebe.com" in parts.netloc:
69
- return f'<iframe class="eaglebe" src="{parts.geturl()}" scrolling="no" width="{config["width"]}">'
70
- #
132
+ return self
71
133
  return None
72
134
 
135
+ @property
136
+ def contents(self):
137
+ return f'<iframe class="eaglebe" src="{self.parts.geturl()}" scrolling="no" width="{self.config["width"]}">'
138
+
73
139
 
74
- class EllohaPlugin(Plugin):
140
+ class EllohaPlugin(BasePlugin):
75
141
  def __call__(self, parts, config={}):
76
142
  if "reservation.elloha.com" in parts.netloc:
77
- # sample :
78
- # {
79
- # "ConstellationWidgetContainer": "917c4c52-c997-4077-9135-873a0b2e0c85",
80
- # "Idoi": "195ea849-1732-4a69-a051-e7911001cd09"
81
- # }
82
- current_lang = config["current_lang"]
83
- extra_params = config["extra_params"]
84
-
85
- error_message = _(
86
- "With an elloha plugin, extra params must contain a dictionary with two keys : ConstellationWidgetContainer, Idoi"
87
- )
88
- error_message = translate(error_message, target_language=current_lang)
89
- error_message = f'<div class="elloha elloha_error">{error_message}</div>'
90
-
91
- if (
92
- extra_params is None
93
- or extra_params[0] != "{"
94
- or extra_params[-1] != "}"
95
- ):
143
+ self.parts = parts
144
+ self.config = config
145
+ return self
146
+ return None
147
+
148
+ @property
149
+ def contents(self):
150
+ # sample :
151
+ # {
152
+ # "ConstellationWidgetContainer": "917c4c52-c997-4077-9135-873a0b2e0c85",
153
+ # "Idoi": "195ea849-1732-4a69-a051-e7911001cd09"
154
+ # }
155
+ current_lang = self.config["current_lang"]
156
+ extra_params = self.config["extra_params"]
157
+ error_message = _(
158
+ "With an elloha plugin, extra params must contain a dictionary with two keys : ConstellationWidgetContainer, Idoi"
159
+ )
160
+ error_message = translate(error_message, target_language=current_lang)
161
+ error_message = f'<div class="elloha elloha_error">{error_message}</div>'
162
+
163
+ if extra_params is None or extra_params[0] != "{" or extra_params[-1] != "}":
164
+ return error_message
165
+ try:
166
+ res = json.loads(extra_params.lower())
167
+ except JSONDecodeError:
168
+ return error_message
169
+
170
+ if res.get("constellationwidgetcontainer") is None or res.get("idoi") is None:
171
+ return error_message
172
+
173
+ cw1 = res.get("constellationwidgetcontainer")
174
+ cw2 = cw1.replace("-", "")
175
+ idoi = res.get("idoi")
176
+ return (
177
+ f'<div class="elloha">'
178
+ f'<div id="ConstellationWidgetContainer{cw1}" '
179
+ f'style="width:100%" data-id-projet="{cw2}">...</div></div>'
180
+ f'<script type="text/javascript" src="{self.parts.geturl()}/Scripts/widget-loader.min.js?v=42"></script>'
181
+ f'<script type="text/javascript">var constellationWidgetUrl{cw2}, '
182
+ f"constellationTypeModule{cw2};"
183
+ f'constellationWidgetUrl{cw2} = "https://reservation.elloha.com/Widget/BookingEngine/{cw1}?idoi={idoi}&culture=fr-FR";'
184
+ f'constellationTypeModule{cw2}=1; constellationWidgetLoad("ConstellationWidgetContainer{cw1}");'
185
+ f'constellationWidgetAddEvent(window, "resize", function () {{constellationWidgetSetAppearance("ConstellationWidgetContainer{cw1}");}});</script>'
186
+ )
187
+
188
+
189
+ class CognitoformPlugin(BasePlugin):
190
+ def __call__(self, parts, config={}):
191
+ if "cognitoforms" in parts.netloc:
192
+ self.parts = parts
193
+ self.config = config
194
+ return self
195
+ return None
196
+
197
+ @property
198
+ def contents(self):
199
+ current_lang = self.config["current_lang"]
200
+ extra_params = self.config["extra_params"]
201
+
202
+ error_message = _(
203
+ "With a cognitoform plugin, extra params can be void but if you complete it you must specify : scrolling:(yes/no) and overflow:(hidden/scroll/auto)"
204
+ )
205
+ error_message = translate(error_message, target_language=current_lang)
206
+ error_message = (
207
+ f'<div class="cognitoform cognitoform_error">{error_message}</div>'
208
+ )
209
+
210
+ if extra_params is None:
211
+ return f'<iframe src="{self.parts.geturl()}" style="border: 0px none; width: {self.config["width"]}%; overflow: auto;" scrolling="yes"></iframe>'
212
+ else:
213
+ if extra_params[0] != "{" or extra_params[-1] != "}":
96
214
  return error_message
97
215
  try:
98
216
  res = json.loads(extra_params.lower())
99
217
  except JSONDecodeError:
100
218
  return error_message
101
219
 
102
- if (
103
- res.get("constellationwidgetcontainer") is None
104
- or res.get("idoi") is None
105
- ):
220
+ if res.get("overflow") is None or res.get("scrolling") is None:
106
221
  return error_message
107
222
 
108
- cw1 = res.get("constellationwidgetcontainer")
109
- cw2 = cw1.replace("-", "")
110
- idoi = res.get("idoi")
111
- return (
112
- f'<div class="elloha">'
113
- f'<div id="ConstellationWidgetContainer{cw1}" '
114
- f'style="width:100%" data-id-projet="{cw2}">...</div></div>'
115
- f'<script type="text/javascript" src="{parts.geturl()}/Scripts/widget-loader.min.js?v=42"></script>'
116
- f'<script type="text/javascript">var constellationWidgetUrl{cw2}, '
117
- f"constellationTypeModule{cw2};"
118
- f'constellationWidgetUrl{cw2} = "https://reservation.elloha.com/Widget/BookingEngine/{cw1}?idoi={idoi}&culture=fr-FR";'
119
- f'constellationTypeModule{cw2}=1; constellationWidgetLoad("ConstellationWidgetContainer{cw1}");'
120
- f'constellationWidgetAddEvent(window, "resize", function () {{constellationWidgetSetAppearance("ConstellationWidgetContainer{cw1}");}});</script>'
121
- )
122
- #
123
- return None
223
+ overflow = res.get("overflow")
224
+ scrolling = res.get("scrolling")
225
+ return f'<iframe src="{self.parts.geturl()}" style="border: 0px none; width: {self.config["width"]}%; overflow: {overflow};" scrolling="{scrolling}"></iframe>'
124
226
 
125
227
 
126
- class CognitoformPlugin(Plugin):
228
+ class ArcgisPlugin(BasePlugin):
127
229
  def __call__(self, parts, config={}):
128
- if "cognitoforms" in parts.netloc:
129
- current_lang = config["current_lang"]
130
- extra_params = config["extra_params"]
230
+ if "arcgis" in parts.netloc:
231
+ self.parts = parts
232
+ self.config = config
233
+ return None
234
+
235
+ @property
236
+ def contents(self):
237
+ # url : https://developers.arcgis.com/
238
+ # extra_params : {"portal_item_id":"27a432b0835149e6acd3ac39d0e4349c"}
239
+ current_lang = self.config["current_lang"]
240
+ extra_params = self.config["extra_params"]
241
+ url = self.config["url"]
242
+
243
+ error_message = _(
244
+ "With arcgis plugin, extra params must contain a dictionary with one key : portal_item_id"
245
+ )
246
+ error_message = translate(error_message, target_language=current_lang)
247
+ error_message = f'<div class="arcgis arcgis_error">{error_message}</div>'
248
+
249
+ if extra_params is None or extra_params[0] != "{" or extra_params[-1] != "}":
250
+ return error_message
251
+ try:
252
+ res = json.loads(extra_params.lower())
253
+ except JSONDecodeError:
254
+ return error_message
255
+ if res.get("portal_item_id") is None:
256
+ return error_message
257
+
258
+ portal_item_id = res.get("portal_item_id")
259
+ msg = _("Consult the map")
260
+ msg = translate(msg, target_language=current_lang)
261
+ return f'<a href="{url}/view_arcgis?portal_item_id={portal_item_id}">{msg}</a>'
131
262
 
132
- error_message = _(
133
- "With a cognitoform plugin, extra params can be void but if you complete it you must specify : scrolling:(yes/no) and overflow:(hidden/scroll/auto)"
134
- )
135
- error_message = translate(error_message, target_language=current_lang)
136
- error_message = (
137
- f'<div class="cognitoform cognitoform_error">{error_message}</div>'
138
- )
139
263
 
140
- if extra_params is None:
141
- return f'<iframe src="{parts.geturl()}" style="border: 0px none; width: {config["width"]}%; overflow: auto;" scrolling="yes"></iframe>'
142
- else:
143
- if extra_params[0] != "{" or extra_params[-1] != "}":
144
- return error_message
145
- try:
146
- res = json.loads(extra_params.lower())
147
- except JSONDecodeError:
148
- return error_message
149
-
150
- if res.get("overflow") is None or res.get("scrolling") is None:
151
- return error_message
152
-
153
- overflow = res.get("overflow")
154
- scrolling = res.get("scrolling")
155
- return f'<iframe src="{parts.geturl()}" style="border: 0px none; width: {config["width"]}%; overflow: {overflow};" scrolling="{scrolling}"></iframe>'
264
+ class GiveADayPlugin(BasePlugin):
265
+ def __call__(self, parts, config={}):
266
+ if "www.giveaday.be" in parts.netloc:
267
+ self.parts = parts
268
+ self.config = config
269
+ return self
156
270
  #
157
271
  return None
158
272
 
273
+ @property
274
+ def contents(self):
275
+ return (
276
+ '<div id="giveaday-widget"></div>'
277
+ "<script src=https://www.giveaday.be/assets/giveaday_v1.js></script>"
278
+ "<script>"
279
+ "function renderWidget() {"
280
+ 'giveADayWidget.initialize("giveaday-widget", 2924, "organization", "large", "fr","#34B78F");}'
281
+ "renderWidget();"
282
+ "</script>"
283
+ )
284
+
285
+
286
+ class IIdeluxWastePlugin(Interface):
287
+ """"""
159
288
 
160
- class ArcgisPlugin(Plugin):
289
+
290
+ @implementer(IIdeluxWastePlugin)
291
+ class IdeluxWastePlugin(BasePlugin):
161
292
  def __call__(self, parts, config={}):
162
- if "arcgis" in parts.netloc:
163
- # url : https://developers.arcgis.com/
164
- # extra_params : {"portal_item_id":"27a432b0835149e6acd3ac39d0e4349c"}
165
- current_lang = config["current_lang"]
166
- extra_params = config["extra_params"]
167
- url = config["url"]
168
-
169
- error_message = _(
170
- "With arcgis plugin, extra params must contain a dictionary with one key : portal_item_id"
171
- )
172
- error_message = translate(error_message, target_language=current_lang)
173
- error_message = f'<div class="arcgis arcgis_error">{error_message}</div>'
174
-
175
- if (
176
- extra_params is None
177
- or extra_params[0] != "{"
178
- or extra_params[-1] != "}"
179
- ):
180
- return error_message
181
- try:
182
- res = json.loads(extra_params.lower())
183
- except JSONDecodeError:
184
- return error_message
185
- if res.get("portal_item_id") is None:
186
- return error_message
293
+ # https://www.odwb.be/api/explore/v2.1/catalog/datasets/guide-de-tri1/records
294
+ if "www.odwb.be" in parts.netloc and "guide-de-tri1" in parts.path:
295
+ self.parts = parts
296
+ self.config = config
297
+ return self
298
+ return None
187
299
 
188
- portal_item_id = res.get("portal_item_id")
189
- msg = _("Consult the map")
190
- msg = translate(msg, target_language=current_lang)
191
- return (
192
- f'<a href="{url}/view_arcgis?portal_item_id={portal_item_id}">{msg}</a>'
300
+ # url = config["url"]
301
+ # return (f'<a href="{url}/view_idelux_waste?portal_item_id={portal_item_id}">{msg}</a>')
302
+ @property
303
+ def contents(self):
304
+ headers = {"Accept": "application/json"}
305
+ try:
306
+ # ?limit=-1 to get all records from an odwb table.
307
+ response = requests.get(
308
+ f"{self.parts.geturl()}?limit=-1", headers=headers, timeout=5
193
309
  )
194
- #
195
- return None
310
+ self.config["extra_params"] = response.json()
311
+ return self.config["extra_params"]
312
+
313
+ except requests.exceptions.Timeout:
314
+ logger.warning(f"Timeout raised for requests : {self.url}")
315
+ return None
316
+
196
317
 
318
+ class IInbwContainersAffluencePlugin(Interface):
319
+ """"""
197
320
 
198
- class GiveADayPlugin(Plugin):
321
+
322
+ @implementer(IInbwContainersAffluencePlugin)
323
+ class InbwContainersAffluencePlugin(BasePlugin):
199
324
  def __call__(self, parts, config={}):
200
- if "www.giveaday.be" in parts.netloc:
201
- return (
202
- '<div id="giveaday-widget"></div>'
203
- "<script src=https://www.giveaday.be/assets/giveaday_v1.js></script>"
204
- "<script>"
205
- "function renderWidget() {"
206
- 'giveADayWidget.initialize("giveaday-widget", 2924, "organization", "large", "fr","#34B78F");}'
207
- "renderWidget();"
208
- "</script>"
209
- )
210
- #
325
+ if "www.odwb.be" in parts.netloc and "affluence" in parts.path:
326
+ self.parts = parts
327
+ self.config = config
328
+ return self
211
329
  return None
212
330
 
331
+ @property
332
+ def contents(self):
333
+ headers = {"Accept": "application/json"}
334
+ try:
335
+ response = requests.get(
336
+ f"{self.parts.geturl()}&limit=-1", headers=headers, timeout=5
337
+ )
338
+ self.config["extra_params"] = json.dumps(response.json())
339
+ return self.config["extra_params"]
340
+ except requests.exceptions.Timeout:
341
+ logger.warning(f"Timeout raised for requests : {self.url}")
342
+ return None
343
+
344
+
345
+ class IOdwbWidgetPlugin(Interface):
346
+ """"""
213
347
 
214
- class UnknowServicePlugin(Plugin):
348
+
349
+ @implementer(IOdwbWidgetPlugin)
350
+ class OdwbWidgetPlugin(BasePlugin):
215
351
  def __call__(self, parts, config={}):
216
- current_lang = config["current_lang"]
352
+ # https://static.opendatasoft.com/ods-widgets
353
+ if "static.opendatasoft.com" in parts.netloc:
354
+ self.is_odwb_widget_plugins = True
355
+ self.parts = parts
356
+ self.config = config
357
+ return self
358
+
359
+ @property
360
+ def contents(self):
361
+ return self.config["extra_params"]
362
+
363
+
364
+ class UnknowServicePlugin(BasePlugin):
365
+ def __call__(self, parts, config={}):
366
+ self.parts = parts
367
+ self.config = config
368
+ return self
369
+
370
+ @property
371
+ def contents(self):
372
+ current_lang = self.config["current_lang"]
217
373
  msg = _("Unknow service")
218
374
  msg = translate(msg, target_language=current_lang)
219
375
  return f'<p class="unknow_service">{msg}</p>'
@@ -226,3 +382,26 @@ class ArcgisView(BrowserView):
226
382
  @property
227
383
  def get_portal_item_id(self):
228
384
  return self.request.portal_item_id
385
+
386
+
387
+ class IdeluxWasteView(BrowserView):
388
+
389
+ def __init__(self, context, request):
390
+ """ """
391
+
392
+
393
+ class InbwContainersAffluenceView(BrowserView):
394
+
395
+ def __init__(self, context, request):
396
+ """ """
397
+
398
+
399
+ class IOdwbWidgetLayer(IDefaultBrowserLayer):
400
+ """ """
401
+
402
+
403
+ @implementer(IOdwbViewUtils, IOdwbWidgetLayer)
404
+ class OdwbWidgetView(BrowserView):
405
+
406
+ def __init__(self, context, request):
407
+ """ """
@@ -56,15 +56,19 @@
56
56
  <tal:dates define="modified context/ModificationDate">
57
57
  <span class="documentModified"
58
58
  tal:condition="modified">
59
- <span i18n:translate="">
60
- Modified
61
- </span>
62
- <span class="pat-display-time"
63
- data-pat-display-time="from-now: true"
64
- tal:attributes="datetime modified"
65
- tal:content="modified">
66
- Modified
67
- </span>
59
+ <a class="documentModified"
60
+ tal:attributes="href string:${context/absolute_url}/@@historyview"
61
+ tal:omit-tag="python:context.portal_type != 'imio.smartweb.SectionText'">
62
+ <span i18n:translate="">
63
+ Modified
64
+ </span>
65
+ <span class="pat-display-time"
66
+ data-pat-display-time="from-now: true"
67
+ tal:attributes="datetime modified"
68
+ tal:content="modified">
69
+ Modified
70
+ </span>
71
+ </a>
68
72
  </span>
69
73
  </tal:dates>
70
74
 
@@ -22,7 +22,7 @@
22
22
  id string:body-section-${context/id}">
23
23
  <tal:cond condition="image">
24
24
  <figure>
25
- <img alt="" tal:attributes="src python:view.get_scale_url(context);" />
25
+ <img tal:attributes="src python:view.get_scale_url(context); alt python:context.image_caption if context.image_caption else ''" />
26
26
  <figcaption tal:condition="context/image_caption" tal:content="context/image_caption"></figcaption>
27
27
  </figure>
28
28
  </tal:cond>
@@ -35,3 +35,10 @@ class IArcgisViewUtils(Interface):
35
35
 
36
36
  class IOgpViewUtils(Interface):
37
37
  """ """
38
+
39
+
40
+ class IOdwbViewUtils(Interface):
41
+ """ """
42
+
43
+ def is_odwb_widget_plugins():
44
+ """Return True if we are in the generic odwb widget plugins"""
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <object>
3
+ <difftypes>
4
+ <type portal_type="imio.smartweb.SectionText">
5
+ <field name="any" difftype="Compound Diff for Dexterity types"/>
6
+ </type>
7
+ </difftypes>
8
+ </object>
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0' encoding='UTF-8'?>
2
2
  <metadata>
3
- <version>1052</version>
3
+ <version>1055</version>
4
4
  <dependencies>
5
5
  <dependency>profile-plone.app.dexterity:default</dependency>
6
6
  <dependency>profile-plone.app.imagecropping:default</dependency>
@@ -19,17 +19,34 @@
19
19
  interface="Products.CMFPlone.interfaces.controlpanel.ISearchSchema"
20
20
  field="types_not_searched">
21
21
  <value purge="false">
22
+ <element>News Item</element>
23
+ <element>imio.smartweb.HeroBanner</element>
24
+ <element>Discussion Item</element>
25
+ <element>MessagesConfig</element>
26
+ <element>Folder</element>
22
27
  <element>imio.smartweb.BlockLink</element>
28
+ <element>Message</element>
29
+ <element>Document</element>
23
30
  <element>imio.smartweb.Footer</element>
24
- <element>imio.smartweb.HeroBanner</element>
31
+ <element>imio.smartweb.SectionHTML</element>
32
+ <element>imio.smartweb.SectionSendinblue</element>
33
+ <element>imio.smartweb.SectionNews</element>
34
+ <element>imio.smartweb.SectionCollection</element>
25
35
  <element>imio.smartweb.SectionContact</element>
36
+ <element>imio.smartweb.SectionExternalContent</element>
37
+ <element>imio.smartweb.SectionSelections</element>
26
38
  <element>imio.smartweb.SectionFiles</element>
27
- <element>imio.smartweb.SectionGallery</element>
28
39
  <element>imio.smartweb.SectionLinks</element>
29
- <element>imio.smartweb.SectionSelections</element>
30
- <element>imio.smartweb.SectionSlide</element>
31
40
  <element>imio.smartweb.SectionText</element>
41
+ <element>imio.smartweb.SectionGallery</element>
42
+ <element>imio.smartweb.SectionMap</element>
43
+ <element>imio.smartweb.SectionPostit</element>
44
+ <element>imio.smartweb.SectionSlide</element>
32
45
  <element>imio.smartweb.SectionVideo</element>
46
+ <element>imio.smartweb.SectionEvents</element>
47
+ <element>Plone Site</element>
48
+ <element>TempFolder</element>
49
+ <element>Event</element>
33
50
  </value>
34
51
  </record>
35
52
 
@@ -2,6 +2,7 @@
2
2
  <repositorytool>
3
3
  <policymap>
4
4
  <type name="imio.smartweb.SectionText">
5
+ <policy name="at_edit_autoversion" />
5
6
  <policy name="version_on_revert"/>
6
7
  </type>
7
8
  </policymap>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3
+ meta_type="Dexterity FTI"
4
+ name="Collection"
5
+ i18n:domain="plone"
6
+ >
7
+
8
+ <!-- Enabled behaviors -->
9
+ <property name="behaviors" purge="false">
10
+ <element value="solr.fields" />
11
+ </property>
12
+
13
+ </object>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3
+ meta_type="Dexterity FTI"
4
+ name="File"
5
+ i18n:domain="plone"
6
+ >
7
+
8
+ <!-- Enabled behaviors -->
9
+ <property name="behaviors" purge="false">
10
+ <element value="solr.fields" />
11
+ </property>
12
+
13
+ </object>