imio.smartweb.core 1.2.91__py3-none-any.whl → 1.3.1__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 (107) hide show
  1. imio/smartweb/core/browser/configure.zcml +16 -0
  2. imio/smartweb/core/browser/controlpanel.py +42 -5
  3. imio/smartweb/core/browser/search/search.py +15 -0
  4. imio/smartweb/core/browser/sitemap.py +155 -107
  5. imio/smartweb/core/browser/utils.py +4 -1
  6. imio/smartweb/core/configure.zcml +5 -1
  7. imio/smartweb/core/contents/__init__.py +2 -0
  8. imio/smartweb/core/contents/rest/base.py +5 -2
  9. imio/smartweb/core/contents/rest/campaign/__init__.py +0 -0
  10. imio/smartweb/core/contents/rest/campaign/configure.zcml +80 -0
  11. imio/smartweb/core/contents/rest/campaign/content.py +83 -0
  12. imio/smartweb/core/contents/rest/campaign/endpoint.py +211 -0
  13. imio/smartweb/core/contents/rest/campaign/view.pt +19 -0
  14. imio/smartweb/core/contents/rest/campaign/view.py +29 -0
  15. imio/smartweb/core/contents/rest/configure.zcml +1 -0
  16. imio/smartweb/core/contents/rest/directory/endpoint.py +11 -3
  17. imio/smartweb/core/contents/rest/events/endpoint.py +11 -3
  18. imio/smartweb/core/contents/rest/news/endpoint.py +11 -3
  19. imio/smartweb/core/contents/rest/search/endpoint.py +4 -1
  20. imio/smartweb/core/contents/rest/utils.py +3 -3
  21. imio/smartweb/core/interfaces.py +6 -0
  22. imio/smartweb/core/overrides.zcml +10 -0
  23. imio/smartweb/core/profiles/default/metadata.xml +1 -1
  24. imio/smartweb/core/profiles/ideabox/browserlayer.xml +7 -0
  25. imio/smartweb/core/profiles/ideabox/metadata.xml +5 -0
  26. imio/smartweb/core/profiles/ideabox/registry/iaideabox.xml +9 -0
  27. imio/smartweb/core/profiles/ideabox/types/imio.smartweb.CampaignView.xml +40 -0
  28. imio/smartweb/core/profiles/ideabox/types/imio.smartweb.Folder.xml +71 -0
  29. imio/smartweb/core/profiles/ideabox/types.xml +17 -0
  30. imio/smartweb/core/profiles/ideabox_uninstall/browserlayer.xml +7 -0
  31. imio/smartweb/core/profiles/ideabox_uninstall/types/imio.smartweb.Folder.xml +25 -0
  32. imio/smartweb/core/profiles/ideabox_uninstall/types.xml +4 -0
  33. imio/smartweb/core/profiles/testing/metadata.xml +1 -0
  34. imio/smartweb/core/profiles/testing/registry.xml +2 -2
  35. imio/smartweb/core/profiles.zcml +18 -0
  36. imio/smartweb/core/subscribers.py +27 -1
  37. imio/smartweb/core/subscribers.zcml +8 -0
  38. imio/smartweb/core/tests/resources/json_ideabox_campaign.json +222 -0
  39. imio/smartweb/core/tests/resources/json_ideabox_campaigns.json +425 -0
  40. imio/smartweb/core/tests/resources/json_ideabox_projects.json +1871 -0
  41. imio/smartweb/core/tests/test_iadeliberations.py +38 -40
  42. imio/smartweb/core/tests/test_ideabox.py +152 -0
  43. imio/smartweb/core/tests/test_procedure.py +7 -3
  44. imio/smartweb/core/tests/test_rest.py +6 -1
  45. imio/smartweb/core/tests/test_sitemap.py +81 -42
  46. imio/smartweb/core/tests/test_vocabularies.py +8 -10
  47. imio/smartweb/core/tests/test_vocabulary.py +18 -0
  48. imio/smartweb/core/upgrades/configure.zcml +16 -1
  49. imio/smartweb/core/upgrades/upgrades.py +64 -0
  50. imio/smartweb/core/utils.py +33 -0
  51. imio/smartweb/core/viewlets/offcanvas.pt +2 -0
  52. imio/smartweb/core/viewlets/ogptags.py +9 -0
  53. imio/smartweb/core/vocabularies.py +35 -4
  54. imio/smartweb/core/vocabularies.zcml +6 -0
  55. imio/smartweb/core/webcomponents/build/css/373.smartweb-webcomponents-compiled.css +1 -1
  56. imio/smartweb/core/webcomponents/build/css/420.smartweb-webcomponents-compiled.css +1 -0
  57. imio/smartweb/core/webcomponents/build/css/486.smartweb-webcomponents-compiled.css +1 -1
  58. imio/smartweb/core/webcomponents/build/css/666.smartweb-webcomponents-compiled.css +1 -0
  59. imio/smartweb/core/webcomponents/build/css/884.smartweb-webcomponents-compiled.css +1 -1
  60. imio/smartweb/core/webcomponents/build/css/919.smartweb-webcomponents-compiled.css +1 -1
  61. imio/smartweb/core/webcomponents/build/css/smartweb-webcomponents-compiled.css +1 -1
  62. imio/smartweb/core/webcomponents/build/js/141.smartweb-webcomponents-compiled.js +2 -0
  63. imio/smartweb/core/webcomponents/build/js/{828.smartweb-webcomponents-compiled.js.LICENSE.txt → 141.smartweb-webcomponents-compiled.js.LICENSE.txt} +3 -3
  64. imio/smartweb/core/webcomponents/build/js/15.smartweb-webcomponents-compiled.js +2 -0
  65. imio/smartweb/core/webcomponents/build/js/21.smartweb-webcomponents-compiled.js +1 -0
  66. imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js +1 -1
  67. imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -5
  68. imio/smartweb/core/webcomponents/build/js/373.smartweb-webcomponents-compiled.js +1 -1
  69. imio/smartweb/core/webcomponents/build/js/486.smartweb-webcomponents-compiled.js +1 -1
  70. imio/smartweb/core/webcomponents/build/js/666.smartweb-webcomponents-compiled.js +1 -0
  71. imio/smartweb/core/webcomponents/build/js/799.smartweb-webcomponents-compiled.js +1 -1
  72. imio/smartweb/core/webcomponents/build/js/824.smartweb-webcomponents-compiled.js +1 -1
  73. imio/smartweb/core/webcomponents/build/js/884.smartweb-webcomponents-compiled.js +1 -1
  74. imio/smartweb/core/webcomponents/build/js/919.smartweb-webcomponents-compiled.js +1 -1
  75. imio/smartweb/core/webcomponents/build/js/922.smartweb-webcomponents-compiled.js +1 -0
  76. imio/smartweb/core/webcomponents/build/js/smartweb-webcomponents-compiled.js +1 -1
  77. imio/smartweb/core/webcomponents/package.json +80 -80
  78. imio/smartweb/core/webcomponents/src/components/Annuaire/Annuaire.scss +1 -0
  79. imio/smartweb/core/webcomponents/src/components/Campaign/Campaign.jsx +306 -0
  80. imio/smartweb/core/webcomponents/src/components/Campaign/Campaign.scss +672 -0
  81. imio/smartweb/core/webcomponents/src/components/Campaign/CampaignCard/CampaignCard.jsx +79 -0
  82. imio/smartweb/core/webcomponents/src/components/Campaign/CampaignContent/CampaignContent.jsx +193 -0
  83. imio/smartweb/core/webcomponents/src/components/Campaign/CampaignList/CampaignList.jsx +67 -0
  84. imio/smartweb/core/webcomponents/src/components/Campaign/Filters/Filter.jsx +259 -0
  85. imio/smartweb/core/webcomponents/src/components/Campaign/index.js +2 -0
  86. imio/smartweb/core/webcomponents/src/components/Filters/MainFilter.scss +1 -0
  87. imio/smartweb/core/webcomponents/src/components/News/NewsContent/NewsContent.jsx +0 -1
  88. imio/smartweb/core/webcomponents/src/components/Search/Search.jsx +54 -9
  89. imio/smartweb/core/webcomponents/src/components/Search/Search.scss +9 -0
  90. imio/smartweb/core/webcomponents/src/hooks/useAxios.js +45 -9
  91. imio/smartweb/core/webcomponents/src/index.jsx +2 -0
  92. imio/smartweb/core/webcomponents/src/index.scss +2 -2
  93. imio/smartweb/core/webcomponents/src/utils/CampaignMap.jsx +177 -0
  94. imio/smartweb/core/webcomponents/src/utils/Map.jsx +1 -1
  95. imio/smartweb/core/webcomponents/src/utils/Map.scss +15 -1
  96. imio/smartweb/core/webcomponents/src/utils/translation.js +247 -199
  97. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/METADATA +24 -1
  98. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/RECORD +105 -72
  99. imio/smartweb/core/webcomponents/build/js/499.smartweb-webcomponents-compiled.js +0 -2
  100. imio/smartweb/core/webcomponents/build/js/828.smartweb-webcomponents-compiled.js +0 -2
  101. /imio/smartweb/core/webcomponents/build/js/{499.smartweb-webcomponents-compiled.js.LICENSE.txt → 15.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
  102. /imio.smartweb.core-1.2.91-py3.12-nspkg.pth → /imio.smartweb.core-1.3.1-py3.12-nspkg.pth +0 -0
  103. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/LICENSE.GPL +0 -0
  104. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/LICENSE.rst +0 -0
  105. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/WHEEL +0 -0
  106. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/namespace_packages.txt +0 -0
  107. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,211 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from imio.smartweb.common.utils import get_vocabulary
4
+ from imio.smartweb.core.contents.rest.base import BaseEndpoint
5
+ from imio.smartweb.core.contents.rest.base import BaseService
6
+ from imio.smartweb.core.utils import get_basic_auth_json
7
+ from imio.smartweb.core.utils import get_ts_api_url
8
+ from plone import api
9
+ from plone.i18n.normalizer import idnormalizer
10
+ from plone.restapi.interfaces import IExpandableElement
11
+ from zope.component import adapter
12
+ from zope.i18n import translate
13
+ from zope.interface import implementer
14
+ from zope.interface import Interface
15
+
16
+ import base64
17
+ import requests
18
+
19
+
20
+ def get_ideabox_basic_auth_header() -> str:
21
+ user = api.portal.get_registry_record("smartweb.iaideabox_api_username")
22
+ pwd = api.portal.get_registry_record("smartweb.iaideabox_api_password")
23
+ usrPass = f"{user}:{pwd}".encode("utf-8")
24
+ b64Val = base64.b64encode(usrPass)
25
+ return f"Basic {b64Val.decode('utf-8')}"
26
+
27
+
28
+ class BaseTsEndpoint(BaseEndpoint):
29
+ def __init__(self, *args, **kwargs):
30
+ super(BaseTsEndpoint, self).__init__(*args, **kwargs)
31
+ self.user = api.portal.get_registry_record("smartweb.iaideabox_api_username")
32
+ self.pwd = api.portal.get_registry_record("smartweb.iaideabox_api_password")
33
+
34
+ def _get_json(self, url):
35
+ return get_basic_auth_json(url, self.user, self.pwd)
36
+
37
+ @property
38
+ def query_url(self):
39
+ raise NotImplementedError("query_url must be defined in subclasses")
40
+
41
+
42
+ @implementer(IExpandableElement)
43
+ @adapter(Interface, Interface)
44
+ class CampaignEndpoint(BaseTsEndpoint):
45
+
46
+ def __call__(self):
47
+ require_keys = [
48
+ "uuid",
49
+ "id",
50
+ "display_name",
51
+ "text",
52
+ "url",
53
+ "api_url",
54
+ "fields",
55
+ "workflow",
56
+ ]
57
+ json = self._get_json(self.query_url)
58
+ json_res = {}
59
+ if not json:
60
+ return {}
61
+ elif "data" in json:
62
+ # list of projects
63
+ json["data"] = self.add_b64_image_to_data(json.get("data"))
64
+ projects = [
65
+ {k: v for k, v in d.items() if k in require_keys}
66
+ for d in json.get("data")
67
+ ]
68
+ json_res["items"] = projects
69
+ json_res["items_total"] = json.get("count")
70
+
71
+ else:
72
+ # single project
73
+ json.pop("evolution")
74
+ json.pop("roles")
75
+ json.pop("submission")
76
+ json.pop("user")
77
+ json_res = json
78
+ # Return a json which represents a project or which contains a list of projects
79
+ return json_res
80
+
81
+ def add_b64_image_to_data(self, data):
82
+ for d in data:
83
+ # get image
84
+ image_url = d.get("fields").get("images_raw")[0].get("image").get("url")
85
+ content = self.get_image(image_url).content
86
+ b64_content = base64.b64encode(content).decode("utf-8")
87
+ d["fields"]["images_raw"][0]["image"]["content"] = b64_content
88
+ return data
89
+
90
+ def get_image(self, image_url):
91
+ if not image_url:
92
+ return
93
+ headers = {"Accept": "image/*"}
94
+ headers["Authorization"] = get_ideabox_basic_auth_header()
95
+ response = requests.get(image_url, headers=headers)
96
+ return response
97
+
98
+ @property
99
+ def query_url(self):
100
+ wcs_api = get_ts_api_url("wcs")
101
+ if "id" in self.request.form:
102
+ # we want a specific project
103
+ project_id = self.request.form.get("id")
104
+ url = f"{wcs_api}/cards/imio-ideabox-projet/{project_id}?full=on"
105
+ else:
106
+ # we want (filtered) list of projects for a specific campaign with eventually extra pamams (zone, topic, ...)
107
+ extra_params = [f"{k}={v}" for k, v in self.request.form.items()]
108
+ extra_params = "&".join(extra_params)
109
+ campaign_id = self.context.linked_campaign
110
+ url = f"{wcs_api}/cards/imio-ideabox-projet/list?filter-campagne={campaign_id}&full=on&filter-statut=Vote|Enregistr%C3%A9e&filter-statut-operator=in&{extra_params}"
111
+ return url
112
+
113
+
114
+ @implementer(IExpandableElement)
115
+ @adapter(Interface, Interface)
116
+ class ZonesEndpoint(BaseTsEndpoint):
117
+
118
+ def __call__(self):
119
+ json = self._get_json(self.query_url)
120
+ json_res = {"items": json["data"], "items_total": json.get("count")}
121
+ return json_res
122
+
123
+ @property
124
+ def query_url(self):
125
+ wcs_api = get_ts_api_url("wcs")
126
+ campaign_id = self.context.linked_campaign
127
+ return f"{wcs_api}/cards/imio-ideabox-zone/list?filter-campagne={campaign_id}"
128
+
129
+
130
+ @implementer(IExpandableElement)
131
+ @adapter(Interface, Interface)
132
+ class TsTopicsEndpoint(BaseTsEndpoint):
133
+
134
+ def __call__(self):
135
+ json = self._get_json(self.query_url)
136
+ json_res = {"items": json["data"], "items_total": json.get("count")}
137
+ return json_res
138
+
139
+ @property
140
+ def query_url(self):
141
+ wcs_api = get_ts_api_url("wcs")
142
+ campaign_id = self.context.linked_campaign
143
+ return f"{wcs_api}/cards/imio-ideabox-theme/list?filter-campagne={campaign_id}"
144
+
145
+
146
+ @implementer(IExpandableElement)
147
+ @adapter(Interface, Interface)
148
+ class TopicsEndpoint(BaseEndpoint):
149
+
150
+ def __call__(self):
151
+ # get all topics from smartweb vocabulary (populate select in React campaign view)
152
+ topics_vocabulary = get_vocabulary("imio.smartweb.vocabulary.Topics")
153
+ current_lang = api.portal.get_current_language()[:2]
154
+ json_res = {
155
+ "items": [
156
+ {
157
+ "value": term.value,
158
+ "title": translate(term.title, target_language=current_lang),
159
+ }
160
+ for term in topics_vocabulary
161
+ ],
162
+ "items_total": len(topics_vocabulary),
163
+ }
164
+ return json_res
165
+
166
+
167
+ @implementer(IExpandableElement)
168
+ @adapter(Interface, Interface)
169
+ class AllTopicsEndpoint(TopicsEndpoint):
170
+
171
+ def __call__(self):
172
+ topics = super(AllTopicsEndpoint, self).__call__()
173
+ ts_endpoint = TsTopicsEndpoint(self.context, self.request)
174
+ ts_topics = ts_endpoint()
175
+ ts_topics = [
176
+ {"title": i.get("text"), "value": i.get("id")} for i in ts_topics["items"]
177
+ ]
178
+ topics["items"].extend(ts_topics)
179
+ topics["items"].sort(key=lambda x: idnormalizer.normalize(x["title"]))
180
+ topics["items_total"] += len(ts_topics)
181
+ return topics
182
+
183
+
184
+ class CampaignEndpointGet(BaseService):
185
+ def reply(self):
186
+ return CampaignEndpoint(self.context, self.request)()
187
+
188
+
189
+ class AuthCampaignEndpointGet(BaseService):
190
+ def reply(self):
191
+ return get_ideabox_basic_auth_header()
192
+
193
+
194
+ class ZonesEndpointGet(BaseService):
195
+ def reply(self):
196
+ return ZonesEndpoint(self.context, self.request)()
197
+
198
+
199
+ class TsTopicsEndpointGet(BaseService):
200
+ def reply(self):
201
+ return ZonesEndpoint(self.context, self.request)()
202
+
203
+
204
+ class TopicsEndpointGet(BaseService):
205
+ def reply(self):
206
+ return TopicsEndpoint(self.context, self.request)()
207
+
208
+
209
+ class AllTopicsEndpointGet(BaseService):
210
+ def reply(self):
211
+ return AllTopicsEndpoint(self.context, self.request)()
@@ -0,0 +1,19 @@
1
+ <html
2
+ metal:use-macro="context/main_template/macros/master"
3
+ i18n:domain="imio.smartweb">
4
+ <body>
5
+ <metal:main fill-slot="content-core">
6
+ <div class="full-width">
7
+ <smartweb-campaign tal:attributes="query-url view/local_query_url;
8
+ query-zones-url view/local_query_zones_url;
9
+ query-topics-url view/local_query_topics_url;
10
+ batch-size view/batch_size;
11
+ propose-url view/propose_url;
12
+ current-language view/current_language;
13
+ display-map view/display_map;
14
+ view-path view/view_path;
15
+ context-authenticated-user view/context_authenticated_user;"></smartweb-campaign>
16
+ </div>
17
+ </metal:main>
18
+ </body>
19
+ </html>
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from imio.smartweb.core.contents.rest.view import BaseRestView
4
+ from imio.smartweb.core.interfaces import IOgpViewUtils
5
+ from plone import api
6
+ from zope.interface import implementer
7
+
8
+
9
+ @implementer(IOgpViewUtils)
10
+ class CampaignViewView(BaseRestView):
11
+ """CampaignView view"""
12
+
13
+ @property
14
+ def propose_url(self):
15
+ return self.context.propose_project_url
16
+
17
+ @property
18
+ def display_map(self):
19
+ return self.context.display_map
20
+
21
+ @property
22
+ def local_query_zones_url(self):
23
+ base_url = self.context.absolute_url()
24
+ return f"{base_url}/@zones"
25
+
26
+ @property
27
+ def local_query_topics_url(self):
28
+ base_url = self.context.absolute_url()
29
+ return f"{base_url}/@all_topics"
@@ -1,6 +1,7 @@
1
1
  <configure
2
2
  xmlns="http://namespaces.zope.org/zope">
3
3
 
4
+ <include package=".campaign" />
4
5
  <include package=".directory" />
5
6
  <include package=".events" />
6
7
  <include package=".news" />
@@ -13,7 +13,7 @@ from zope.interface import Interface
13
13
 
14
14
  class BaseDirectoryEndpoint(BaseEndpoint):
15
15
  def __call__(self):
16
- results = super(BaseDirectoryEndpoint, self).__call__()
16
+ results = super(BaseDirectoryEndpoint, self).__call__() or {}
17
17
  if not results.get("items"):
18
18
  return results
19
19
  orientation = self.context.orientation
@@ -45,10 +45,13 @@ class BaseDirectoryEndpoint(BaseEndpoint):
45
45
  "metadata_fields=taxonomy_contact_category",
46
46
  "metadata_fields=topics",
47
47
  "metadata_fields=has_leadimage",
48
- "fullobjects=1",
48
+ "fullobjects={}".format(self.fullobjects),
49
49
  "sort_on=sortable_title",
50
- "b_size={}".format(self.context.nb_results),
51
50
  ]
51
+ if self.batch_size == 0:
52
+ params.append("b_size={}".format(self.context.nb_results))
53
+ else:
54
+ params.append("b_size={}".format(self.batch_size))
52
55
  if self.context.selected_categories is not None:
53
56
  for category in self.context.selected_categories:
54
57
  params.append(f"taxonomy_contact_category.query={category}")
@@ -74,6 +77,11 @@ class DirectoryEndpointGet(BaseService):
74
77
  def reply(self):
75
78
  return DirectoryEndpoint(self.context, self.request)()
76
79
 
80
+ def reply_for_given_object(self, obj, request, fullobjects=1, batch_size=0):
81
+ return DirectoryEndpoint(
82
+ obj, request, fullobjects=fullobjects, batch_size=batch_size
83
+ )()
84
+
77
85
 
78
86
  class DirectoryFiltersEndpointGet(BaseService):
79
87
  def reply(self):
@@ -12,7 +12,7 @@ from zope.interface import Interface
12
12
 
13
13
  class BaseEventsEndpoint(BaseEndpoint):
14
14
  def __call__(self):
15
- results = super(BaseEventsEndpoint, self).__call__()
15
+ results = super(BaseEventsEndpoint, self).__call__() or {}
16
16
  if not results or not results.get("items"):
17
17
  return results
18
18
  orientation = self.context.orientation
@@ -43,9 +43,12 @@ class BaseEventsEndpoint(BaseEndpoint):
43
43
  "metadata_fields=has_leadimage",
44
44
  "metadata_fields=UID",
45
45
  "sort_on=event_dates",
46
- "fullobjects=1",
47
- "b_size={}".format(self.context.nb_results),
46
+ "fullobjects={}".format(self.fullobjects),
48
47
  ]
48
+ if self.batch_size == 0:
49
+ params.append("b_size={}".format(self.context.nb_results))
50
+ else:
51
+ params.append("b_size={}".format(self.batch_size))
49
52
  if self.context.selected_event_types is not None:
50
53
  for event_type in self.context.selected_event_types:
51
54
  params.append(f"event_type={event_type}")
@@ -70,6 +73,11 @@ class EventsEndpointGet(BaseService):
70
73
  def reply(self):
71
74
  return EventsEndpoint(self.context, self.request)()
72
75
 
76
+ def reply_for_given_object(self, obj, request, fullobjects=1, batch_size=0):
77
+ return EventsEndpoint(
78
+ obj, request, fullobjects=fullobjects, batch_size=batch_size
79
+ )()
80
+
73
81
 
74
82
  class EventsFiltersEndpointGet(BaseService):
75
83
  def reply(self):
@@ -12,7 +12,7 @@ from zope.interface import Interface
12
12
 
13
13
  class BaseNewsEndpoint(BaseEndpoint):
14
14
  def __call__(self):
15
- results = super(BaseNewsEndpoint, self).__call__()
15
+ results = super(BaseNewsEndpoint, self).__call__() or {}
16
16
  if not results.get("items"):
17
17
  return results
18
18
  orientation = self.context.orientation
@@ -46,9 +46,12 @@ class BaseNewsEndpoint(BaseEndpoint):
46
46
  "metadata_fields=UID",
47
47
  "sort_on=effective",
48
48
  "sort_order=descending",
49
- "b_size={}".format(self.context.nb_results),
50
- "fullobjects=1",
49
+ "fullobjects={}".format(self.fullobjects),
51
50
  ]
51
+ if self.batch_size == 0:
52
+ params.append("b_size={}".format(self.context.nb_results))
53
+ else:
54
+ params.append("b_size={}".format(self.batch_size))
52
55
  params = self.construct_query_string(params)
53
56
  url = f"{NEWS_URL}/{self.remote_endpoint}?{params}"
54
57
  return url
@@ -70,6 +73,11 @@ class NewsEndpointGet(BaseService):
70
73
  def reply(self):
71
74
  return NewsEndpoint(self.context, self.request)()
72
75
 
76
+ def reply_for_given_object(self, obj, request, fullobjects=1, batch_size=0):
77
+ return NewsEndpoint(
78
+ obj, request, fullobjects=fullobjects, batch_size=batch_size
79
+ )()
80
+
73
81
 
74
82
  class NewsFiltersEndpointGet(BaseService):
75
83
  def reply(self):
@@ -57,7 +57,10 @@ def get_default_view_url(view_type):
57
57
  if not record:
58
58
  return ""
59
59
  with api.env.adopt_user(username="admin"):
60
- return api.content.get(UID=record).absolute_url()
60
+ obj = api.content.get(UID=record)
61
+ if not obj:
62
+ return ""
63
+ return obj.absolute_url()
61
64
 
62
65
 
63
66
  def get_views_mapping(navigation_root):
@@ -69,10 +69,10 @@ def get_auth_sources_response(
69
69
  "v": wf_status,
70
70
  },
71
71
  ],
72
- "metadata_fields": ["title", "modified"],
72
+ "metadata_fields": ["title", "modified", "id"],
73
73
  "sort_on": "effective",
74
74
  "sort_order": "descending",
75
- "fullobjects": True,
75
+ "fullobjects": False,
76
76
  "b_start": 0,
77
77
  "b_size": 4000,
78
78
  }
@@ -81,7 +81,7 @@ def get_auth_sources_response(
81
81
  auth = get_wca_token(client_id, client_secret)
82
82
  headers = {
83
83
  "Accept": "application/json",
84
- "Content-Type": "text/plain",
84
+ "Content-Type": "application/json",
85
85
  "Authorization": auth,
86
86
  }
87
87
  url = f"{url}/@querystring-search"
@@ -5,6 +5,7 @@ from collective.messagesviewlet.interfaces import ICollectiveMessagesviewletLaye
5
5
  from collective.solr.browser.interfaces import IThemeSpecific
6
6
  from imio.smartweb.common.interfaces import IImioSmartwebCommonLayer
7
7
  from plone.app.contenttypes.interfaces import IPloneAppContenttypesLayer
8
+ from Products.CMFPlone.browser.interfaces import ISiteMap
8
9
  from zope.interface import Interface
9
10
 
10
11
 
@@ -22,10 +23,15 @@ class IImioSmartwebCoreLayer(
22
23
  ILayerSpecific,
23
24
  IThemeSpecific,
24
25
  ICollectiveMessagesviewletLayer,
26
+ ISiteMap,
25
27
  ):
26
28
  """Marker interface that defines a browser layer."""
27
29
 
28
30
 
31
+ class IImioIdeaboxLayer(Interface):
32
+ """Marker interface that defines a browser layer."""
33
+
34
+
29
35
  class IArcgisViewUtils(Interface):
30
36
  """ """
31
37
 
@@ -0,0 +1,10 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope">
3
+
4
+ <adapter
5
+ for="plone.dexterity.interfaces.IDexterityContainer"
6
+ factory="imio.smartweb.core.contents.rest.campaign.content.CampaignNameChooser"
7
+ provides="zope.container.interfaces.INameChooser"
8
+ />
9
+
10
+ </configure>
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0' encoding='UTF-8'?>
2
2
  <metadata>
3
- <version>1064</version>
3
+ <version>1066</version>
4
4
  <dependencies>
5
5
  <dependency>profile-plone.app.dexterity:default</dependency>
6
6
  <dependency>profile-plone.app.imagecropping:default</dependency>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layers>
3
+ <layer
4
+ name="imio.smartweb.core.ideabox"
5
+ interface="imio.smartweb.core.interfaces.IImioIdeaboxLayer"
6
+ />
7
+ </layers>
@@ -0,0 +1,5 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <metadata>
3
+ <version>1062</version>
4
+ <description>Profile to enable Ideabox on an existing Plone6 site</description>
5
+ </metadata>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <registry
3
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
4
+ i18n:domain="imio.smartweb">
5
+
6
+ <records interface="imio.smartweb.core.browser.controlpanel.ISmartwebControlPanel"
7
+ prefix="smartweb" />
8
+
9
+ </registry>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0"?>
2
+ <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3
+ name="imio.smartweb.CampaignView"
4
+ meta_type="Dexterity FTI"
5
+ i18n:domain="imio.smartweb">
6
+
7
+ <!-- Basic properties -->
8
+ <property
9
+ i18n:translate=""
10
+ name="title">Campaign view</property>
11
+ <property
12
+ i18n:translate=""
13
+ name="description">Display projects from a campaign coming from e-guichet.</property>
14
+
15
+ <property name="icon_expr">string:file-earmark-person</property>
16
+
17
+ <!-- Hierarchy control -->
18
+ <property name="global_allow">True</property>
19
+ <!-- Schema, class and security -->
20
+ <property name="add_permission">imio.smartweb.core.ManageRestViews</property>
21
+ <property name="klass">imio.smartweb.core.contents.CampaignView</property>
22
+ <property name="schema">imio.smartweb.core.contents.ICampaignView</property>
23
+
24
+ <!-- Enabled behaviors -->
25
+ <property name="behaviors" purge="false">
26
+ <element value="plone.excludefromnavigation"/>
27
+ <element value="plone.shortname"/>
28
+ <element value="plone.publication"/>
29
+ <element value="plone.locking"/>
30
+ <element value="plone.leadimage"/>
31
+ <element value="plone.imagecropping"/>
32
+ <element value="imio.smartweb.listing"/>
33
+ <element value="imio.smartweb.topics"/>
34
+ <element value="imio.smartweb.iam"/>
35
+ <element value="plone.categorization"/>
36
+ <element value="collective.autopublishing.behavior.IAutoPublishing"/>
37
+ <element value="solr.fields" />
38
+ </property>
39
+
40
+ </object>
@@ -0,0 +1,71 @@
1
+ <?xml version="1.0"?>
2
+ <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3
+ name="imio.smartweb.Folder"
4
+ meta_type="Dexterity FTI"
5
+ i18n:domain="imio.smartweb">
6
+
7
+ <!-- Basic properties -->
8
+ <property
9
+ i18n:translate=""
10
+ name="title">Folder</property>
11
+ <property
12
+ i18n:translate=""
13
+ name="description">Folder content type to structure website</property>
14
+
15
+ <property name="icon_expr">string:folder2</property>
16
+
17
+ <!-- Hierarchy control -->
18
+ <property name="global_allow">True</property>
19
+ <property name="filter_content_types">True</property>
20
+ <property name="allowed_content_types">
21
+ <element value="Collection" />
22
+ <element value="Message" />
23
+ <element value="Link" />
24
+ <element value="imio.smartweb.CampaignView" />
25
+ <element value="imio.smartweb.CirkwiView" />
26
+ <element value="imio.smartweb.DirectoryView" />
27
+ <element value="imio.smartweb.EventsView" />
28
+ <element value="imio.smartweb.Folder" />
29
+ <element value="imio.smartweb.NewsView" />
30
+ <element value="imio.smartweb.Page" />
31
+ <element value="imio.smartweb.PortalPage" />
32
+ <element value="imio.smartweb.Procedure" />
33
+ <element value="collective.pivot.Family" />
34
+ </property>
35
+
36
+ <!-- Schema, class and security -->
37
+ <property name="add_permission">imio.smartweb.core.AddFolder</property>
38
+ <property name="klass">imio.smartweb.core.contents.Folder</property>
39
+ <property name="schema">imio.smartweb.core.contents.IFolder</property>
40
+
41
+ <!-- Enabled behaviors -->
42
+ <property name="behaviors" purge="false">
43
+ <element value="plone.categorization"/>
44
+ <element value="plone.namefromtitle"/>
45
+ <element value="plone.excludefromnavigation"/>
46
+ <element value="plone.shortname"/>
47
+ <element value="plone.basic"/>
48
+ <element value="plone.locking"/>
49
+ <element value="plone.leadimage"/>
50
+ <element value="plone.imagecropping"/>
51
+ <element value="plone.constraintypes"/>
52
+ <element value="imio.smartweb.orientation"/>
53
+ <element value="imio.smartweb.listing"/>
54
+ <element value="imio.smartweb.quickaccessselection"/>
55
+ <element value="collective.autopublishing.behavior.IAutoPublishing"/>
56
+ <element value="solr.fields" />
57
+ </property>
58
+
59
+ <!-- View information -->
60
+ <property name="default_view">summary_view</property>
61
+ <property name="default_view_fallback">False</property>
62
+ <property name="immediate_view">view</property>
63
+ <property name="view_methods">
64
+ <element value="block_view"/>
65
+ <element value="block_view_with_images"/>
66
+ <element value="summary_view"/>
67
+ <element value="summary_view_with_images"/>
68
+ <element value="element_view"/>
69
+ </property>
70
+
71
+ </object>
@@ -0,0 +1,17 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <object name="portal_types" meta_type="Plone Types Tool">
3
+ <object meta_type="Dexterity FTI" name="imio.smartweb.CampaignView"/>
4
+ <object meta_type="Dexterity FTI" name="imio.smartweb.Folder"/>
5
+ <object meta_type="Dexterity FTI" name="imio.smartweb.Footer"/>
6
+ <object meta_type="Dexterity FTI" name="imio.smartweb.HeroBanner"/>
7
+ <object meta_type="Dexterity FTI" name="imio.smartweb.Page"/>
8
+ <object meta_type="Dexterity FTI" name="imio.smartweb.PortalPage"/>
9
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionCollection"/>
10
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionFiles"/>
11
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionGallery"/>
12
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionHTML"/>
13
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionLinks"/>
14
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionSelections"/>
15
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionText"/>
16
+ <object meta_type="Dexterity FTI" name="imio.smartweb.SectionVideo"/>
17
+ </object>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layers>
3
+ <layer
4
+ name="imio.smartweb.core.ideabox"
5
+ remove="True"
6
+ />
7
+ </layers>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0"?>
2
+ <object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3
+ name="imio.smartweb.Folder"
4
+ meta_type="Dexterity FTI"
5
+ i18n:domain="imio.smartweb">
6
+
7
+ <!-- Hierarchy control -->
8
+ <property name="global_allow">True</property>
9
+ <property name="filter_content_types">True</property>
10
+ <property name="allowed_content_types">
11
+ <element value="Collection" />
12
+ <element value="Message" />
13
+ <element value="Link" />
14
+ <element value="imio.smartweb.CirkwiView" />
15
+ <element value="imio.smartweb.DirectoryView" />
16
+ <element value="imio.smartweb.EventsView" />
17
+ <element value="imio.smartweb.Folder" />
18
+ <element value="imio.smartweb.NewsView" />
19
+ <element value="imio.smartweb.Page" />
20
+ <element value="imio.smartweb.PortalPage" />
21
+ <element value="imio.smartweb.Procedure" />
22
+ <element value="collective.pivot.Family" />
23
+ </property>
24
+
25
+ </object>
@@ -0,0 +1,4 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <object name="portal_types" meta_type="Plone Types Tool">
3
+ <object name="imio.smartweb.CampaignView" remove="True" />
4
+ </object>
@@ -2,6 +2,7 @@
2
2
  <metadata>
3
3
  <dependencies>
4
4
  <dependency>profile-imio.smartweb.core:default</dependency>
5
+ <dependency>profile-imio.smartweb.core:ideabox</dependency>
5
6
  <dependency>profile-collective.taxonomy:examples</dependency>
6
7
  </dependencies>
7
8
  </metadata>