Commit 2d026303 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_web_renderjs_ui: Use RJS Skin to check consistency

parent 661f04f3
...@@ -12,39 +12,44 @@ if not context.getAvailableLanguageList(): ...@@ -12,39 +12,44 @@ if not context.getAvailableLanguageList():
if context.getSkinSelectionName() != 'RJS': if context.getSkinSelectionName() != 'RJS':
return [] return []
# find the .js containing translation data try:
gadget_translation_data_js = context.WebSite_getTranslationDataWebScriptValue() context.getPortalObject().changeSkin("RJS")
if gadget_translation_data_js is None:
return [] # find the .js containing translation data
gadget_translation_data_js = context.WebSite_getTranslationDataWebScriptValue()
error_list = [] if gadget_translation_data_js is None:
if context.WebSite_getTranslationDataTextContent( return []
) != gadget_translation_data_js.getTextContent():
error_list.append("Translation data script content is not up to date") error_list = []
if context.WebSite_getTranslationDataTextContent(
if fixit: ) != gadget_translation_data_js.getTextContent():
# try to detect the case of two incompatible web sites configured for the same translation gadget. error_list.append("Translation data script content is not up to date")
# 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. if fixit:
# Using REQUEST is not really good, since upgrader uses grouped activities and we can just check # try to detect the case of two incompatible web sites configured for the same translation gadget.
# web sites processed in the same activity group, but that's easy and hopefully better than nothing. # Use a mapping of set of web site ids keyed by translation data script reference and check
already_updated_websites = container.REQUEST.get( # if we update the same translation data script more than once in the same REQUEST.
script.getId(), defaultdict(set)) # Using REQUEST is not really good, since upgrader uses grouped activities and we can just check
container.REQUEST.set(script.getId(), already_updated_websites) # web sites processed in the same activity group, but that's easy and hopefully better than nothing.
gadget_translation_data_js_reference = gadget_translation_data_js.getReference() already_updated_websites = container.REQUEST.get(
already_updated_websites[gadget_translation_data_js_reference].add(context.getId()) script.getId(), defaultdict(set))
if len(already_updated_websites[gadget_translation_data_js_reference]) > 1: container.REQUEST.set(script.getId(), already_updated_websites)
raise RuntimeError( gadget_translation_data_js_reference = gadget_translation_data_js.getReference()
"Translation script %s is used by more than one web site with different configurations (%s)" already_updated_websites[gadget_translation_data_js_reference].add(context.getId())
% ( if len(already_updated_websites[gadget_translation_data_js_reference]) > 1:
gadget_translation_data_js_reference, raise RuntimeError(
", ".join(already_updated_websites[gadget_translation_data_js_reference]), "Translation script %s is used by more than one web site with different configurations (%s)"
)) % (
gadget_translation_data_js_reference,
context.WebSite_updateTranslationData() ", ".join(already_updated_websites[gadget_translation_data_js_reference]),
# since we might have modified some cached files, check again the modification date ))
# consistency.
error_list.extend( context.WebSite_updateTranslationData()
context.WebSite_checkCacheModificationDateConsistency(fixit=True)) # since we might have modified some cached files, check again the modification date
# consistency.
return error_list error_list.extend(
context.WebSite_checkCacheModificationDateConsistency(fixit=True))
return error_list
finally:
context.getPortalObject().changeSkin("View")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment