imio.smartweb.common 1.2.16__py3-none-any.whl → 1.2.18__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.
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ from imio.smartweb.common.widgets.select import TranslatedAjaxSelectFieldWidget
3
4
  from imio.smartweb.locales import SmartwebMessageFactory as _
4
- from plone.app.z3cform.widget import AjaxSelectFieldWidget
5
5
  from plone.autoform import directives
6
6
  from plone.autoform.interfaces import IFormFieldProvider
7
7
  from plone.supermodel import model
@@ -21,4 +21,4 @@ class ITopics(model.Schema):
21
21
  default=[],
22
22
  required=False,
23
23
  )
24
- directives.widget(topics=AjaxSelectFieldWidget)
24
+ directives.widget(topics=TranslatedAjaxSelectFieldWidget)
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ from imio.smartweb.common.utils import activate_sending_data_to_odwb_for_staging
3
4
  from imio.smartweb.common.utils import is_staging_or_local
4
5
  from plone import api
5
6
  from plone.restapi.services import Service
@@ -30,6 +31,8 @@ class OdwbService(Service):
30
31
  def available(self):
31
32
  staging_or_local = is_staging_or_local()
32
33
  if staging_or_local:
34
+ if activate_sending_data_to_odwb_for_staging() is True:
35
+ return True
33
36
  logger.info(
34
37
  "Don't send odwb data when we are in staging or local environment"
35
38
  )
@@ -0,0 +1,61 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from imio.smartweb.common.testing import IMIO_SMARTWEB_COMMON_INTEGRATION_TESTING
4
+ from imio.smartweb.common.widgets.select import TranslatedAjaxSelectWidget
5
+ from plone.api import portal as portal_api
6
+ from zope.publisher.browser import TestRequest
7
+
8
+ import mock
9
+ import unittest
10
+
11
+
12
+ class TestVocabulary(unittest.TestCase):
13
+ layer = IMIO_SMARTWEB_COMMON_INTEGRATION_TESTING
14
+
15
+ def setUp(self):
16
+ """Custom shared utility setup for tests"""
17
+ self.request = TestRequest()
18
+
19
+ def test_translated_ajax_select(self):
20
+ portal_api.get_current_language = mock.Mock(return_value="fr")
21
+ widget = TranslatedAjaxSelectWidget(self.request)
22
+ widget.update()
23
+ self.assertEqual(
24
+ {
25
+ "name": None,
26
+ "value": "",
27
+ "pattern": "select2",
28
+ "pattern_options": {"separator": ";"},
29
+ },
30
+ widget._base_args(),
31
+ )
32
+
33
+ widget.vocabulary = "imio.smartweb.vocabulary.Topics"
34
+ self.assertEqual(
35
+ widget._base_args(),
36
+ {
37
+ "name": None,
38
+ "value": "",
39
+ "pattern": "select2",
40
+ "pattern_options": {
41
+ "vocabularyUrl": "http://nohost/plone/@@getVocabulary?name=imio.smartweb.vocabulary.Topics",
42
+ "separator": ";",
43
+ },
44
+ },
45
+ )
46
+ widget.value = "entertainment"
47
+ self.assertEqual(
48
+ widget._base_args(),
49
+ {
50
+ "name": None,
51
+ "value": "entertainment",
52
+ "pattern": "select2",
53
+ "pattern_options": {
54
+ "vocabularyUrl": "http://nohost/plone/@@getVocabulary?name=imio.smartweb.vocabulary.Topics",
55
+ "initialValues": {
56
+ "entertainment": "Activités et divertissement",
57
+ },
58
+ "separator": ";",
59
+ },
60
+ },
61
+ )
@@ -184,8 +184,6 @@ def is_staging_or_local():
184
184
  if scheme == "http" and re.search(pattern, netloc):
185
185
  return True
186
186
  elif scheme == "https" and "staging" in netloc:
187
- if activate_sending_data_to_odwb_for_staging() is True:
188
- return False
189
187
  return True
190
188
  else:
191
189
  return False
File without changes
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from plone import api
4
+ from plone.app.z3cform.widget import AjaxSelectWidget
5
+ from z3c.form.interfaces import IFieldWidget
6
+ from z3c.form.widget import FieldWidget
7
+ from zope.interface import implementer
8
+ from zope.i18n import translate
9
+
10
+
11
+ class TranslatedAjaxSelectWidget(AjaxSelectWidget):
12
+ """Translated Ajax select widget for z3c.form."""
13
+
14
+ def _ajaxselect_options(self):
15
+ options = super(TranslatedAjaxSelectWidget, self)._ajaxselect_options()
16
+ current_lang = api.portal.get_current_language()[:2]
17
+ translated_initial_values = {}
18
+ for token, value in list(options.get("initialValues", {}).items()):
19
+ translated_initial_values[token] = translate(
20
+ value, domain="imio.smartweb", target_language=current_lang
21
+ )
22
+ if translated_initial_values:
23
+ options["initialValues"] = translated_initial_values
24
+ return options
25
+
26
+
27
+ @implementer(IFieldWidget)
28
+ def TranslatedAjaxSelectFieldWidget(field, request, extra=None):
29
+ if extra is not None:
30
+ request = extra
31
+ return FieldWidget(field, TranslatedAjaxSelectWidget(request))
@@ -0,0 +1,3 @@
1
+ import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('imio',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('imio', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('imio', [os.path.dirname(p)])));m = m or sys.modules.setdefault('imio', types.ModuleType('imio'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
2
+ import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('imio',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('imio', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('imio', [os.path.dirname(p)])));m = m or sys.modules.setdefault('imio', types.ModuleType('imio'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
3
+ import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('imio', 'smartweb'));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('imio.smartweb', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('imio.smartweb', [os.path.dirname(p)])));m = m or sys.modules.setdefault('imio.smartweb', types.ModuleType('imio.smartweb'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p);m and setattr(sys.modules['imio'], 'smartweb', m)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imio.smartweb.common
3
- Version: 1.2.16
3
+ Version: 1.2.18
4
4
  Summary: Common utilities, vocabularies, taxonomies for imio.smartweb & co products
5
5
  Home-page: https://github.com/imio/imio.smartweb.common
6
6
  Author: iMio
@@ -18,6 +18,8 @@ Classifier: Framework :: Plone :: 6.0
18
18
  Classifier: Programming Language :: Python
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
21
23
  Classifier: Operating System :: OS Independent
22
24
  Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
23
25
  Requires-Python: >=3.8
@@ -28,8 +30,8 @@ Requires-Dist: z3c.jbot
28
30
  Requires-Dist: z3c.unconfigure
29
31
  Requires-Dist: beautifulsoup4
30
32
  Requires-Dist: geopy
31
- Requires-Dist: Products.GenericSetup >=1.8.2
32
- Requires-Dist: plone.api >=1.8.4
33
+ Requires-Dist: Products.GenericSetup (>=1.8.2)
34
+ Requires-Dist: plone.api (>=1.8.4)
33
35
  Requires-Dist: plone.restapi
34
36
  Requires-Dist: plone.app.dexterity
35
37
  Requires-Dist: plone.app.imagecropping
@@ -45,7 +47,7 @@ Requires-Dist: imio.smartweb.locales
45
47
  Requires-Dist: more-itertools
46
48
  Provides-Extra: test
47
49
  Requires-Dist: plone.app.testing ; extra == 'test'
48
- Requires-Dist: plone.testing >=5.0.0 ; extra == 'test'
50
+ Requires-Dist: plone.testing (>=5.0.0) ; extra == 'test'
49
51
  Requires-Dist: plone.app.robotframework[debug] ; extra == 'test'
50
52
  Requires-Dist: plone.restapi[test] ; extra == 'test'
51
53
  Requires-Dist: freezegun ; extra == 'test'
@@ -161,6 +163,24 @@ Changelog
161
163
  =========
162
164
 
163
165
 
166
+ 1.2.18 (2024-07-01)
167
+ -------------------
168
+
169
+ - WEB-4088 : Refactor code for odwb staging availability
170
+ [boulch]
171
+
172
+ - GHA tests on Python 3.8 3.9 and 3.10
173
+ [remdub]
174
+
175
+
176
+ 1.2.17 (2024-06-06)
177
+ -------------------
178
+
179
+ - WEB-4113 : Add `TranslatedAjaxSelectFieldWidget` to fix translations of initial
180
+ values in select2 fields
181
+ [laulaz]
182
+
183
+
164
184
  1.2.16 (2024-05-30)
165
185
  -------------------
166
186
 
@@ -1,4 +1,4 @@
1
- imio.smartweb.common-1.2.16-py3.11-nspkg.pth,sha256=XZ3YhlzwpUCC8tXtelHRqxVxo3NWomIiMsUfUshrbeE,1011
1
+ imio.smartweb.common-1.2.18-py3.10-nspkg.pth,sha256=wnCUSUElqssZ5FI3x-9HqwD229HQ-bAuPoDUNJHmMtU,1684
2
2
  imio/smartweb/common/__init__.py,sha256=Na9XBfEQUMrm2c5jbqQgwWeg40ih0aXVG1vT8NeAjMQ,2709
3
3
  imio/smartweb/common/adapters.py,sha256=rLlObjqZm3hs2hgUT-LmJytwhT-E1rTvbpIi0mmKQqY,610
4
4
  imio/smartweb/common/adapters.zcml,sha256=ndYNj0J_BFfVpX_7JhY2asSwLzXG-WmjLdfwL9hX_No,254
@@ -18,13 +18,13 @@ imio/smartweb/common/subscribers.py,sha256=pbPQJ1YrfPlYCfxLAJ5sOy_5OToAfs2egX68z
18
18
  imio/smartweb/common/subscribers.zcml,sha256=8v2lqNNVAHlrh2G3jtjVgr3Asrw8WJLS9jSX5U6juFg,971
19
19
  imio/smartweb/common/testing.py,sha256=GKlYMHJUSxZFVX0o_R_c_Au1VYlkd-GjykQqfONHv7I,1985
20
20
  imio/smartweb/common/testing.zcml,sha256=7N-ALtklyWeLSzZmlxN2Tp-aZe_3An--w_6BGl1991E,172
21
- imio/smartweb/common/utils.py,sha256=jzNLR41JVehAxqqQV2WaUiYkB1V6xpMpPGE-G3JJ7Pc,7041
21
+ imio/smartweb/common/utils.py,sha256=S4Kygk-ukllxNdNOLX6D0Zl5SDVoWaS2JqV7MbGuBkA,6952
22
22
  imio/smartweb/common/vocabularies.py,sha256=QRIOWLOALzZDM92o1iUTWgDBBcrdd9BYz7miNjpYCDA,3835
23
23
  imio/smartweb/common/vocabularies.zcml,sha256=iFJer5q3wabBp_EZivPPVUqI1_9w5P_Ft1RGJB5Yqxs,940
24
24
  imio/smartweb/common/behaviors/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
25
25
  imio/smartweb/common/behaviors/configure.zcml,sha256=RfGH8DIybHpxxe2HUsjH2QKSiWYpV7lCZhGN6KLFwCw,531
26
26
  imio/smartweb/common/behaviors/iam.py,sha256=17ON7M6FHXOM_8NOHT_QnJJuAIs4diWCrguHP6Lh5oA,825
27
- imio/smartweb/common/behaviors/topics.py,sha256=mguoFXN5XjcGXvA5HeV_l7-gJ5eR0hfjN1nbXYogcWw,832
27
+ imio/smartweb/common/behaviors/topics.py,sha256=K9XkhTBxxp_nBBeQ-ovUpmOc6raXIiYqmzJtlKVdhbI,863
28
28
  imio/smartweb/common/browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  imio/smartweb/common/browser/collective_taxonomy_controlpanel.py,sha256=QngrsXOIjOt0xHEt2r0W66CPg5msY4H7mDkRaAEGQdg,3044
30
30
  imio/smartweb/common/browser/configure.zcml,sha256=1cDR2cy7O6WX33cFmbJU971wxg22LkLJYiMKCmBTWrA,3177
@@ -71,7 +71,7 @@ imio/smartweb/common/profiles/testing/types/Folder.xml,sha256=RPxIPgViAK0GGGTPKb
71
71
  imio/smartweb/common/profiles/uninstall/browserlayer.xml,sha256=glaCGlITwc36-1Fi2z0VCbLcoQ5GddkAhuW-SGYeZy8,130
72
72
  imio/smartweb/common/rest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  imio/smartweb/common/rest/configure.zcml,sha256=8hQGCvo1EMGFe9cNUpGOcH7spKhUkglFRnRkd9IJ2eE,301
74
- imio/smartweb/common/rest/odwb.py,sha256=36g6Hs_i6FfliKWA63ELlE3_89B_zp-p99Zo_BKGYhM,2072
74
+ imio/smartweb/common/rest/odwb.py,sha256=zRZxowUaE76xlW_blc92vRCzToUpnzw3O5mxFXaeScU,2249
75
75
  imio/smartweb/common/rest/search_filters.py,sha256=upZAZ6h50qiSXo0q22lUgNlcmX5elFtrIQs_jFBl1-s,3832
76
76
  imio/smartweb/common/rest/utils.py,sha256=9zc5ge_DmVuexxN09c3U6QAITAI1s2hc0m6eZuylSxM,1269
77
77
  imio/smartweb/common/sharing/__init__.py,sha256=I_cdzTAnsdb8tEO2kg2lzRkeA7wIGPqHKzu7LBxDwtk,56
@@ -97,6 +97,7 @@ imio/smartweb/common/tests/test_utils.py,sha256=S4QrNVvkHv3Oxp45fWQ65dmGsk7POgUn
97
97
  imio/smartweb/common/tests/test_viewlets.py,sha256=NVEZWEmYo4K_-81Q6w-JTx2nT_3NBcJCl3946MAUnhU,1738
98
98
  imio/smartweb/common/tests/test_vocabularies.py,sha256=C-78USTvOHljuMSLkNb9onSRxLEJmBQLpktetAO74RE,848
99
99
  imio/smartweb/common/tests/test_vocabulary.py,sha256=4E5i5znt_hLhnnRay1iBaOZRmQyFJs8-OMdPm4iSGSg,1638
100
+ imio/smartweb/common/tests/test_widgets.py,sha256=FQ2FphLRZQ1yuMngQ6cu4LxDaLVTAg1VyIUILV0XRUI,2009
100
101
  imio/smartweb/common/tests/resources/image.png,sha256=GBnPJt2ALEefn8GJAY1Lh8o9L6l6G77GJSyS0uveHvQ,1185
101
102
  imio/smartweb/common/tests/resources/image_1400x800.png,sha256=Iy3bWGH4NBlgYC5BolZiNYFTKmCm0_I9MZDZo4sw_V4,30604
102
103
  imio/smartweb/common/tests/resources/image_1800x700.png,sha256=aQcMisSFQO78c6QX4mO7qIfDb9SDRmfzTuPjxMJ_0HM,32643
@@ -132,10 +133,12 @@ imio/smartweb/common/viewlets/privacy.pt,sha256=bAD-I6s3LUgkh30vyTbP3pNUZQYua1Kx
132
133
  imio/smartweb/common/viewlets/privacy.py,sha256=H752etTTIFCM0wTwjESQFl0PStJfCoSRfcePSUQOp8E,449
133
134
  imio/smartweb/common/viewlets/skip_to_content.pt,sha256=FFfTxvRl8V52FzFE6In6B34ApgShNntvMp6F1qwfL0g,376
134
135
  imio/smartweb/common/viewlets/skip_to_content.py,sha256=wm22NUf8Qh5uzz8p4vkLCdFNiDv9zUGAueRyXAIXQDo,496
135
- imio.smartweb.common-1.2.16.dist-info/LICENSE.GPL,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
136
- imio.smartweb.common-1.2.16.dist-info/LICENSE.rst,sha256=5dd78Fdt0e-oM2ICBrMpjHnT8vEP-jhBDF7akXni6B4,655
137
- imio.smartweb.common-1.2.16.dist-info/METADATA,sha256=bBz92b0w6IdWYYo6S7iK0SrTqpBx454D-WwWXFNEuYw,14991
138
- imio.smartweb.common-1.2.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
139
- imio.smartweb.common-1.2.16.dist-info/namespace_packages.txt,sha256=Pg8AH8t9viMMW1hJbNZvTy_n2jXG2igIYUpon5RA4Js,19
140
- imio.smartweb.common-1.2.16.dist-info/top_level.txt,sha256=ZktC0EGzThvMTAin9_q_41rzvvfMT2FYbP8pbhSLMSA,5
141
- imio.smartweb.common-1.2.16.dist-info/RECORD,,
136
+ imio/smartweb/common/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
137
+ imio/smartweb/common/widgets/select.py,sha256=vfVdbecH7qDfJvWV6TfkpqocD6AA5G4yIq7XqSOuVNw,1142
138
+ imio.smartweb.common-1.2.18.dist-info/LICENSE.GPL,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
139
+ imio.smartweb.common-1.2.18.dist-info/LICENSE.rst,sha256=5dd78Fdt0e-oM2ICBrMpjHnT8vEP-jhBDF7akXni6B4,655
140
+ imio.smartweb.common-1.2.18.dist-info/METADATA,sha256=P5mFU_mOorocwaR_kfMvdIOmohdXTlxFNG5yuMdbwFk,15423
141
+ imio.smartweb.common-1.2.18.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
142
+ imio.smartweb.common-1.2.18.dist-info/namespace_packages.txt,sha256=Pg8AH8t9viMMW1hJbNZvTy_n2jXG2igIYUpon5RA4Js,19
143
+ imio.smartweb.common-1.2.18.dist-info/top_level.txt,sha256=ZktC0EGzThvMTAin9_q_41rzvvfMT2FYbP8pbhSLMSA,5
144
+ imio.smartweb.common-1.2.18.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: bdist_wheel (0.40.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,2 +0,0 @@
1
- import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('imio',));importlib = __import__('importlib.util');__import__('importlib.machinery');m = sys.modules.setdefault('imio', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('imio', [os.path.dirname(p)])));m = m or sys.modules.setdefault('imio', types.ModuleType('imio'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
2
- import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('imio', 'smartweb'));importlib = __import__('importlib.util');__import__('importlib.machinery');m = sys.modules.setdefault('imio.smartweb', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('imio.smartweb', [os.path.dirname(p)])));m = m or sys.modules.setdefault('imio.smartweb', types.ModuleType('imio.smartweb'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p);m and setattr(sys.modules['imio'], 'smartweb', m)