Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
3ab8e40d
Commit
3ab8e40d
authored
Feb 28, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
erp5_web_renderjs_ui: Use RJS Skin to check consistency
See merge request
nexedi/erp5!1888
parents
3c307e6a
5fcd5812
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
36 deletions
+46
-36
bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs/WebSite_checkTranslationConsistency.py
.../erp5_web_renderjs/WebSite_checkTranslationConsistency.py
+46
-36
No files found.
bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs/WebSite_checkTranslationConsistency.py
View file @
3ab8e40d
...
@@ -12,39 +12,49 @@ if not context.getAvailableLanguageList():
...
@@ -12,39 +12,49 @@ if not context.getAvailableLanguageList():
if
context
.
getSkinSelectionName
()
!=
'RJS'
:
if
context
.
getSkinSelectionName
()
!=
'RJS'
:
return
[]
return
[]
# find the .js containing translation data
portal
=
context
.
getPortalObject
()
gadget_translation_data_js
=
context
.
WebSite_getTranslationDataWebScriptValue
()
current_skin_selection
=
portal
.
getSkinNameFromRequest
(
context
.
REQUEST
)
if
gadget_translation_data_js
is
None
:
if
not
current_skin_selection
:
return
[]
current_skin_selection
=
portal
.
portal_skins
.
getDefaultSkin
()
error_list
=
[]
try
:
if
context
.
WebSite_getTranslationDataTextContent
(
portal
.
changeSkin
(
context
.
getSkinSelectionName
())
)
!=
gadget_translation_data_js
.
getTextContent
():
error_list
.
append
(
"Translation data script content is not up to date"
)
# find the .js containing translation data
gadget_translation_data_js
=
context
.
WebSite_getTranslationDataWebScriptValue
()
if
fixit
:
if
gadget_translation_data_js
is
None
:
# try to detect the case of two incompatible web sites configured for the same translation gadget.
return
[]
# Use a mapping of set of web site ids keyed by translation data script reference and check
# if we update the same translation data script more than once in the same REQUEST.
error_list
=
[]
# Using REQUEST is not really good, since upgrader uses grouped activities and we can just check
if
context
.
WebSite_getTranslationDataTextContent
(
# web sites processed in the same activity group, but that's easy and hopefully better than nothing.
)
!=
gadget_translation_data_js
.
getTextContent
():
already_updated_websites
=
container
.
REQUEST
.
get
(
error_list
.
append
(
"Translation data script content is not up to date"
)
script
.
getId
(),
defaultdict
(
set
))
container
.
REQUEST
.
set
(
script
.
getId
(),
already_updated_websites
)
if
fixit
:
gadget_translation_data_js_reference
=
gadget_translation_data_js
.
getReference
()
# try to detect the case of two incompatible web sites configured for the same translation gadget.
already_updated_websites
[
gadget_translation_data_js_reference
].
add
(
context
.
getId
())
# Use a mapping of set of web site ids keyed by translation data script reference and check
if
len
(
already_updated_websites
[
gadget_translation_data_js_reference
])
>
1
:
# if we update the same translation data script more than once in the same REQUEST.
raise
RuntimeError
(
# Using REQUEST is not really good, since upgrader uses grouped activities and we can just check
"Translation script %s is used by more than one web site with different configurations (%s)"
# web sites processed in the same activity group, but that's easy and hopefully better than nothing.
%
(
already_updated_websites
=
container
.
REQUEST
.
get
(
gadget_translation_data_js_reference
,
script
.
getId
(),
defaultdict
(
set
))
", "
.
join
(
already_updated_websites
[
gadget_translation_data_js_reference
]),
container
.
REQUEST
.
set
(
script
.
getId
(),
already_updated_websites
)
))
gadget_translation_data_js_reference
=
gadget_translation_data_js
.
getReference
()
already_updated_websites
[
gadget_translation_data_js_reference
].
add
(
context
.
getId
())
context
.
WebSite_updateTranslationData
()
if
len
(
already_updated_websites
[
gadget_translation_data_js_reference
])
>
1
:
# since we might have modified some cached files, check again the modification date
raise
RuntimeError
(
# consistency.
"Translation script %s is used by more than one web site with different configurations (%s)"
error_list
.
extend
(
%
(
context
.
WebSite_checkCacheModificationDateConsistency
(
fixit
=
True
))
gadget_translation_data_js_reference
,
", "
.
join
(
already_updated_websites
[
gadget_translation_data_js_reference
]),
return
error_list
))
context
.
WebSite_updateTranslationData
()
# since we might have modified some cached files, check again the modification date
# consistency.
error_list
.
extend
(
context
.
WebSite_checkCacheModificationDateConsistency
(
fixit
=
True
))
return
error_list
finally
:
portal
.
changeSkin
(
current_skin_selection
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment