Commit 2fee6617 authored by Jérome Perrin's avatar Jérome Perrin

core/administration: reimplement Base_viewDict as a page template

and move it to erp5_administration, this is not a "core" feature but
just a developer tool.

It was used in a few tests, move all the tests in testERP5Administration
parent 7f8b931d
......@@ -2,14 +2,10 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -24,18 +20,6 @@
<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>
......@@ -49,13 +33,25 @@
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewDict</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
......
<html>
<body>
<table width="100%" tal:define="pformat nocall: modules/pprint/pformat">
<tal:block tal:repeat="item python: sorted(modules['six'].iteritems(context.showDict()))">
<tr tal:attributes="bgcolor python: '#dddd88' if repeat['item'].odd() else '#88dddd'">
<td tal:content="python: item[0]" />
<td><pre tal:content="python: pformat(item[1])" /></td>
</tr>
</tal:block>
</table>
</body>
</html>
\ No newline at end of file
......@@ -174,6 +174,26 @@ class TestERP5Administration(InventoryAPITestCase):
'Category group/level1/test_group on object %s is missing.' % person.getRelativeUrl(),
str(consistency_error.getTranslatedMessage()))
def test_Base_viewDict(self):
# modules and documents
self.assertTrue(self.portal.person_module.Base_viewDict())
self.assertTrue(self.portal.person_module.newContent().Base_viewDict())
# base categories and categories
base_category = self.portal.portal_categories.contentValues()[0]
self.assertTrue(base_category.Base_viewDict())
self.assertTrue(base_category.newContent().Base_viewDict())
self.assertTrue(base_category.Base_viewDict()) # base category with content
# workflows
workflow = self.portal.portal_workflow.newContent(portal_type='Workflow')
state = workflow.newContent(portal_type='Workflow State', title='Some State')
self.assertTrue(state.Base_viewDict())
transition = workflow.newContent(portal_type='Workflow Transition',
title='Some Transition')
transition.setReference('change_something')
transition.setGuardRoleList(['Assignee', 'Assignor'])
transition.setCategoryList('destination/' + transition.getPath())
self.assertTrue(transition.Base_viewDict())
def test_suite():
suite = unittest.TestSuite()
......
......@@ -280,18 +280,6 @@ class TestERP5Category(ERP5TypeTestCase):
self.assertEqual(len(om['2'].getRelatedValueList('abc')), 1)
self.assertEqual(len(om['2'].Base_zSearchRelatedObjectsByCategory(category_uid = om['2'].getUid())),1)
def test_09_Base_viewDictWithCategoryWithSubCategory(
self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
self.logMessage('Make sure Base_viewDict is working for categories with sub categories')
portal_categories = self.getCategoryTool()
base_category = portal_categories.activity
self.assertTrue(len(base_category.Base_viewDict())>0)
base_category.newContent(id='toto',title='Toto')
self.assertTrue(len(base_category.Base_viewDict())>0)
def test_getAcquiredCategoryList(self):
# create a base category
ctool = self.getCategoryTool()
......
......@@ -239,20 +239,6 @@ class TestERP5Workflow(ERP5TypeTestCase):
def test_InteractionGuards(self):
self.test_TransitionGuards(transition_type='Interaction Workflow Interaction')
def test_Base_viewDict(self):
"""
verify that Base_viewDict view can be accessed
"""
workflow = self.workflow_module.newContent(portal_type='Workflow')
state = workflow.newContent(portal_type='Workflow State', title='Some State')
state.Base_viewDict()
transition = workflow.newContent(portal_type='Workflow Transition',
title='Some Transition')
transition.setReference('change_something')
transition.setGuardRoleList(['Assignee', 'Assignor'])
transition.setCategoryList('destination/' + transition.getPath())
transition.Base_viewDict()
# XXX: When ERP5Workflow was designed for Configurator, it was deemed
# necessary for WorkflowTool to not be viewable by Anonymous but
# DCWorkflow portal_workflow inherits all permissions from the Site
......
......@@ -418,10 +418,6 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
self.assertEqual(tuple(getattr(text_document3, permission_key)),
('Assignee', 'Assignor', 'Auditor', 'Author'))
def test_15_testGuardsAreNotMessingUpBase_viewDict(self):
# check Base_viewDict is available on workflow's transition
self.workflow.transition_delete_action.Base_viewDict()
def test_16_testWorklistViewIsAccessible(self):
# check worklist view is available on workflow
self.workflow.worklist_1_draft_test_workflow_document_list.view()
......
def escape(data):
"""
Escape &, <, and > in a string of data.
This is a copy of the xml.sax.saxutils.escape function.
"""
# must do ampersand first
data = data.replace("&", "&amp;")
data = data.replace(">", "&gt;")
data = data.replace("<", "&lt;")
return data
from pprint import pformat
ret = '<html><body><table width=100%>\n'
property_dict = context.showDict().items()
i = 0
for k,v in sorted(property_dict):
if (i % 2) == 0:
c = '#88dddd'
else:
c = '#dddd88'
i += 1
ret += '<tr bgcolor="%s"><td >%s</td><td><pre>%s</pre></td></tr>\n' % (escape(c), escape(k), escape(pformat(v)))
ret += '</table></body></html>\n'
return ret
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