Commit 637d1e3a authored by Ayush Tiwari's avatar Ayush Tiwari

ERP5CatalogTool: Display view for portal_catalog when we access it on ERP5 UI

Before this change, `index_html` for Catalog Tool was None that means trying to
access view for CatalogTool from UI always make a function call to the
` __call__` which function was overridden with `searchResults`, which
means everytime someone tried to access `portal_catalog/`, a useless query was
being made and an undesirable query result was displyed on the UI.

In this case, `index_html` is prefered whenever we try to access portal_catalog
from UI.
Also, add test for proper display of view when CatalogTool is accessed from XHTML UI
parent 1e3acb66
...@@ -184,6 +184,13 @@ class ERP5CatalogTool(BaseTool, CMFCore_CatalogTool): ...@@ -184,6 +184,13 @@ class ERP5CatalogTool(BaseTool, CMFCore_CatalogTool):
**kw **kw
) )
security.declareProtected(Permissions.View, 'index_html')
def index_html(self):
"""
Override index_html to display the view for Catalog Tool
"""
return self.view()
security.declarePrivate('getCatalogUrl') security.declarePrivate('getCatalogUrl')
def getCatalogUrl(self, object): def getCatalogUrl(self, object):
return self.__url(object) return self.__url(object)
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
from random import randint from random import randint
import sys import sys
import unittest import unittest
import httplib
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime from DateTime import DateTime
...@@ -3811,6 +3812,18 @@ VALUES ...@@ -3811,6 +3812,18 @@ VALUES
finally: finally:
catalog.setSqlCatalogObjectListList(catalog_method_list) catalog.setSqlCatalogObjectListList(catalog_method_list)
def test_publish_catalog(self):
"""When catalog is published by zope, it does not issue a catalog search but
renders the default view.
"""
ret = self.publish(
self.portal.portal_catalog.getPath(),
basic='ERP5TypeTestCase:')
self.assertEqual(httplib.OK, ret.getStatus())
# check if we did not just publish the result of `str(portal_catalog.__call__())`,
# but a proper page
self.assertIn('<title>Catalog Tool - portal_catalog', ret.getBody())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Catalog)) suite.addTest(unittest.makeSuite(TestERP5Catalog))
......
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