Commit 0eef97ec authored by Jérome Perrin's avatar Jérome Perrin

web_renderjs_ui: update gadget_translation_data.js in post-upgrade

parent 32419c72
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>translation_signature_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>WebSite_checkTranslationConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
if not context.getAvailableLanguageList():
return []
translation_gadget_url = context.getLayoutProperty("configuration_translation_gadget_url")
# XXX - We only support gadget_translation.html as translation gadget, because
# we know that this gadget uses gadget_translation.js for its translation data
if translation_gadget_url != 'gadget_translation.html':
return []
portal = context.getPortalObject()
gadget_translation_data_js = context.getDocumentValue('gadget_translation_data.js')
if gadget_translation_data_js is None:
return ["translation data does not exist"]
signature = portal.Localizer.erp5_ui.get_translated_messages_signature(
language_list=context.getAvailableLanguageList(),
)
error_list = []
gadget_translation_data_js_version = gadget_translation_data_js.getVersion() or ''
if signature not in gadget_translation_data_js_version:
error_list.append(
"Translation data gadget_translation_data.js has different version from Localizer")
if fixit:
context.Base_createTranslateData(
translation_data_file='gadget_translation_data.js',
batch_mode=True)
gadget_translation_data_js.setVersion(signature)
return error_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_checkTranslationConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -119,3 +119,23 @@ class TestRenderJSUpgrade(ERP5TypeTestCase):
[
'Error: Web Site %s references a non existant appcache %s' % (self.web_site.getRelativeUrl(), non_existant_appcache)
], [str(m.getMessage()) for m in self.web_site.checkConsistency()])
def test_upgrade_site_translation(self):
self.web_site.setProperty(
'configuration_translation_gadget_url', 'gadget_translation.html')
self.web_site.setAvailableLanguageList(['en', 'fa'])
self.portal.web_page_module.rjs_gadget_translation_data_js.setVersion('wrong')
self.tic()
self.assertEqual(
['Translation data gadget_translation_data.js has different version from Localizer'],
[str(m.getMessage()) for m in self.web_site.checkConsistency()])
self.web_site.fixConsistency()
self.tic()
self.assertEqual(
[],
[str(m.getMessage()) for m in self.web_site.checkConsistency()])
self.assertNotEqual(
self.portal.web_page_module.rjs_gadget_translation_data_js.getVersion(),
'wrong')
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