imio.smartweb.common 1.2.16__py3-none-any.whl → 1.2.17__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.
- imio/smartweb/common/behaviors/topics.py +2 -2
- imio/smartweb/common/tests/test_widgets.py +61 -0
- imio/smartweb/common/widgets/__init__.py +0 -0
- imio/smartweb/common/widgets/select.py +31 -0
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/METADATA +9 -1
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/RECORD +12 -9
- /imio.smartweb.common-1.2.16-py3.11-nspkg.pth → /imio.smartweb.common-1.2.17-py3.11-nspkg.pth +0 -0
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/LICENSE.GPL +0 -0
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/LICENSE.rst +0 -0
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/WHEEL +0 -0
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/namespace_packages.txt +0 -0
- {imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/top_level.txt +0 -0
|
@@ -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=
|
|
24
|
+
directives.widget(topics=TranslatedAjaxSelectFieldWidget)
|
|
@@ -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
|
+
)
|
|
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))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: imio.smartweb.common
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.17
|
|
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
|
|
@@ -161,6 +161,14 @@ Changelog
|
|
|
161
161
|
=========
|
|
162
162
|
|
|
163
163
|
|
|
164
|
+
1.2.17 (2024-06-06)
|
|
165
|
+
-------------------
|
|
166
|
+
|
|
167
|
+
- WEB-4113 : Add `TranslatedAjaxSelectFieldWidget` to fix translations of initial
|
|
168
|
+
values in select2 fields
|
|
169
|
+
[laulaz]
|
|
170
|
+
|
|
171
|
+
|
|
164
172
|
1.2.16 (2024-05-30)
|
|
165
173
|
-------------------
|
|
166
174
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
imio.smartweb.common-1.2.
|
|
1
|
+
imio.smartweb.common-1.2.17-py3.11-nspkg.pth,sha256=XZ3YhlzwpUCC8tXtelHRqxVxo3NWomIiMsUfUshrbeE,1011
|
|
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
|
|
@@ -24,7 +24,7 @@ imio/smartweb/common/vocabularies.zcml,sha256=iFJer5q3wabBp_EZivPPVUqI1_9w5P_Ft1
|
|
|
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=
|
|
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
|
|
@@ -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
|
|
136
|
-
imio
|
|
137
|
-
imio.smartweb.common-1.2.
|
|
138
|
-
imio.smartweb.common-1.2.
|
|
139
|
-
imio.smartweb.common-1.2.
|
|
140
|
-
imio.smartweb.common-1.2.
|
|
141
|
-
imio.smartweb.common-1.2.
|
|
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.17.dist-info/LICENSE.GPL,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
139
|
+
imio.smartweb.common-1.2.17.dist-info/LICENSE.rst,sha256=5dd78Fdt0e-oM2ICBrMpjHnT8vEP-jhBDF7akXni6B4,655
|
|
140
|
+
imio.smartweb.common-1.2.17.dist-info/METADATA,sha256=JSs5I9lmfEo-eKA4m96TnRIXC7FIYwANeUBFn9i6EdE,15154
|
|
141
|
+
imio.smartweb.common-1.2.17.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
142
|
+
imio.smartweb.common-1.2.17.dist-info/namespace_packages.txt,sha256=Pg8AH8t9viMMW1hJbNZvTy_n2jXG2igIYUpon5RA4Js,19
|
|
143
|
+
imio.smartweb.common-1.2.17.dist-info/top_level.txt,sha256=ZktC0EGzThvMTAin9_q_41rzvvfMT2FYbP8pbhSLMSA,5
|
|
144
|
+
imio.smartweb.common-1.2.17.dist-info/RECORD,,
|
/imio.smartweb.common-1.2.16-py3.11-nspkg.pth → /imio.smartweb.common-1.2.17-py3.11-nspkg.pth
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imio.smartweb.common-1.2.16.dist-info → imio.smartweb.common-1.2.17.dist-info}/top_level.txt
RENAMED
|
File without changes
|