Commit 2471a65d authored by Ayush Tiwari's avatar Ayush Tiwari

[erp5_core] Revert view for Historical Comparison.

Partial revert from 2f121c19
parent 99e67338
...@@ -130,21 +130,20 @@ ...@@ -130,21 +130,20 @@
<td>title</td> <td>title</td>
</tr> </tr>
<tr> <tr>
<td>assertElementPresent</td> <td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[2]</td>
<td></td> <td>Title 0</td> <!-- before -->
</tr> </tr>
<tr> <tr>
<td>storeEval</td> <td>assertText</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[3]</td>
<td>_data_gadget_value</td> <td>Version 1</td> <!-- after -->
</tr> </tr>
<tr> <tr>
<td>verifyEval</td> <td>assertText</td>
<td>storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[4]</td>
<td>---+++@@-1+1@@-Title0+Version1</td> <td>Version 3</td> <!-- now -->
</tr> </tr>
</tal:block> </tal:block>
<tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'"> <tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'">
...@@ -191,21 +190,20 @@ ...@@ -191,21 +190,20 @@
<td>title</td> <td>title</td>
</tr> </tr>
<tr> <tr>
<td>assertElementPresent</td> <td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[2]</td>
<td></td> <td>Version 1</td> <!-- before -->
</tr> </tr>
<tr> <tr>
<td>storeEval</td> <td>assertText</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[3]</td>
<td>_data_gadget_value</td> <td>Version 2</td> <!-- after -->
</tr> </tr>
<tr> <tr>
<td>verifyEval</td> <td>assertText</td>
<td>storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[4]</td>
<td>---+++@@-1+1@@-Version1+Version2</td> <td>Version 3</td> <!-- now -->
</tr> </tr>
</tal:block> </tal:block>
<tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'"> <tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'">
...@@ -270,21 +268,20 @@ ...@@ -270,21 +268,20 @@
<td>title</td> <td>title</td>
</tr> </tr>
<tr> <tr>
<td>assertElementPresent</td> <td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[2]</td>
<td></td> <td>Version 2</td> <!-- before -->
</tr> </tr>
<tr> <tr>
<td>storeEval</td> <td>assertText</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[3]</td>
<td>_data_gadget_value</td> <td>Version 3</td> <!-- after -->
</tr> </tr>
<tr> <tr>
<td>verifyEval</td> <td>assertText</td>
<td>storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td> <td>//tr[@class='listbox-data-line-0 DataA']/td[4]</td>
<td>---+++@@-1+1@@-Version2+Version3</td> <td>Version 3</td> <!-- now -->
</tr> </tr>
</tal:block> </tal:block>
<tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'"> <tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'">
......
...@@ -130,32 +130,19 @@ ...@@ -130,32 +130,19 @@
<tr> <tr>
<td>verifyText</td> <td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[2]</td> <td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[2]</td>
<td>Diff Viewer</td> <td>Old Value</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe</td>
<td></td>
</tr> </tr>
<tr> <tr>
<td>pause</td> <td>verifyText</td>
<td>1000</td> <td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[3]</td>
<td></td> <td>New Value</td>
</tr>
<!-- Check for the value of diff in Iframe -->
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.contentWindow.document.body.textContent</td>
<td>diff_content</td>
</tr> </tr>
<tr> <tr>
<td>verifyEval</td> <td>verifyText</td>
<!-- Verify the value after removing the spaces and line breaks --> <td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[4]</td>
<td>storedVars['diff_content'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td> <td>Current Value</td>
<td>1-1+Anewfoo</td>
</tr> </tr>
</tbody></table> </tbody></table>
</body> </body>
</html> </html>
\ No newline at end of file
from Products.ERP5Type.Document import newTempBase from Products.PythonScripts.standard import Object
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from zExceptions import Unauthorized from zExceptions import Unauthorized
Base_translateString = context.Base_translateString Base_translateString = context.Base_translateString
portal = context.getPortalObject()
portal_diff = portal.portal_diff
try: try:
context.HistoricalRevisions[serial] context.HistoricalRevisions[serial]
except (ConflictError, Unauthorized): except (ConflictError, Unauthorized):
raise raise
except Exception: except Exception: # POSKeyError
return [newTempBase(portal, Base_translateString('Historical revisions are' return [Object(property_name=Base_translateString('Historical revisions are'
' not available, maybe the database has been packed'))] ' not available, maybe the database has been packed'))]
if next_serial == '0.0.0.0': if next_serial == '0.0.0.0':
# In case the next serial is 0.0.0.0, we should always be considering the
# new object as the current context
new_getProperty = context.getProperty new_getProperty = context.getProperty
new = context
else: else:
new = context.HistoricalRevisions[next_serial] new = context.HistoricalRevisions[next_serial]
new_getProperty = new.getProperty new_getProperty = new.getProperty
old = context.HistoricalRevisions[serial] old = context.HistoricalRevisions[serial]
result = [] result = []
# XXX: Instead of creating a separate property list here, we can use DiffTool binary_data_explanation = Base_translateString("Binary data can't be displayed")
# to directly find out the beautified diff and send it to the listbox base_error_message = Base_translateString('(value retrieval failed)')
diff = portal_diff.diffPortalObject(old, new).asBeautifiedJSONDiff() for prop_dict in context.getPropertyMap():
prop = prop_dict['id']
error = False
try:
current_value = context.getProperty(prop)
except TypeError:
error = True
current_value = base_error_message
try:
old_value = old.getProperty(prop)
except TypeError:
error = True
old_value = base_error_message
try:
new_value = new_getProperty(prop)
except TypeError:
error = True
new_value = base_error_message
if new_value != old_value or error:
# check if values are unicode convertible (binary are not)
if isinstance(new_value, (str, unicode)):
try:
unicode(str(new_value), 'utf-8')
except UnicodeDecodeError:
new_value = binary_data_explanation
if isinstance(old_value, (str, unicode)):
try:
unicode(str(old_value), 'utf-8')
except UnicodeDecodeError:
old_value = binary_data_explanation
if isinstance(current_value, (str, unicode)):
try:
unicode(str(current_value), 'utf-8')
except UnicodeDecodeError:
current_value = binary_data_explanation
tempbase_list = [] result.append( Object( property_name=prop,
uid = 900 new_value=new_value,
for x in diff: old_value=old_value,
temp_obj = newTempBase(portal, current_value=current_value))
x['path'], return result
**x)
temp_obj.setUid('new_%s' % uid)
uid = uid + 1
tempbase_list.append(temp_obj)
return tempbase_list
...@@ -90,9 +90,7 @@ ...@@ -90,9 +90,7 @@
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <value>
<list> <list/>
<string>listbox_diff</string>
</list>
</value> </value>
</item> </item>
<item> <item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>css_class</string>
<string>default</string>
<string>gadget_url</string>
<string>js_sandbox</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_diff</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string>listbox-gadget</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_gadget_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Diff Viewer</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.diff</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: field.restrictedTraverse(\'gadget_erp5_side_by_side_diff.html\').absolute_url()</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.Base_getDiffGadgetSandbox()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,7 +50,6 @@ class TestXHTMLMixin(ERP5TypeTestCase): ...@@ -50,7 +50,6 @@ class TestXHTMLMixin(ERP5TypeTestCase):
# some forms have intentionally empty listbox selections like RSS generators # some forms have intentionally empty listbox selections like RSS generators
FORM_LISTBOX_EMPTY_SELECTION_PATH_LIST = ['erp5_web_widget_library/WebSection_viewContentListAsRSS', FORM_LISTBOX_EMPTY_SELECTION_PATH_LIST = ['erp5_web_widget_library/WebSection_viewContentListAsRSS',
'erp5_core/Base_viewHistoricalComparison',
'erp5_diff/ERP5Site_viewDiffTwoObjectDialog',] 'erp5_diff/ERP5Site_viewDiffTwoObjectDialog',]
JSL_IGNORE_FILE_LIST = ( JSL_IGNORE_FILE_LIST = (
'diff2html.js', 'diff2html.js',
......
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