Commit 44a604bb authored by Sebastien Robin's avatar Sebastien Robin

acknowledgement tool: getUnreadDocumentUrlList was return also draft documents by mistake

parent fae19bf9
...@@ -70,6 +70,13 @@ class AcknowledgementTool(BaseTool): ...@@ -70,6 +70,13 @@ class AcknowledgementTool(BaseTool):
""" """
return len(self.getUnreadAcknowledgementList(*args, **kw)) return len(self.getUnreadAcknowledgementList(*args, **kw))
def _getAcknowledgementTypeList(self):
"""
Return list of acknowledgement types, should use portal types group
when we see need of having several portal types for acknowledgements
"""
return ('Acknowledgement',)
security.declarePublic('getUnreadAcknowledgementList') security.declarePublic('getUnreadAcknowledgementList')
def getUnreadAcknowledgementList(self, portal_type=None, user_name=None, def getUnreadAcknowledgementList(self, portal_type=None, user_name=None,
url_list=None): url_list=None):
...@@ -131,7 +138,7 @@ class AcknowledgementTool(BaseTool): ...@@ -131,7 +138,7 @@ class AcknowledgementTool(BaseTool):
# so not in a final state # so not in a final state
final_state_list = self.getPortalCurrentInventoryStateList() final_state_list = self.getPortalCurrentInventoryStateList()
query = NegatedQuery(Query(simulation_state=final_state_list)) query = NegatedQuery(Query(simulation_state=final_state_list))
for x in self.portal_catalog(portal_type = portal_type, for x in self.portal_catalog(portal_type = self._getAcknowledgementTypeList(),
query=query, query=query,
# start_date = {'query':now,'range':'max'}, # start_date = {'query':now,'range':'max'},
# stop_date = {'query':now,'range':'min'}, # stop_date = {'query':now,'range':'min'},
......
...@@ -60,13 +60,20 @@ class TestAcknowledgementTool(ERP5TypeTestCase): ...@@ -60,13 +60,20 @@ class TestAcknowledgementTool(ERP5TypeTestCase):
title="foo", title="foo",
start_date = now-2, start_date = now-2,
stop_date = now+2) stop_date = now+2)
portal.portal_workflow.doActionFor(event, 'start_action')
self.assertEqual(event.getSimulationState(), 'started')
self.tic() self.tic()
acknowledgement_tool_kw = {} acknowledgement_tool_kw = {}
acknowledgement_tool_kw['user_name'] = 'seb' acknowledgement_tool_kw['user_name'] = 'seb'
acknowledgement_tool_kw['portal_type'] = event_type acknowledgement_tool_kw['portal_type'] = event_type
# draft document must be not be part of acknowledgements
document_url_list = portal.portal_acknowledgements\
.getUnreadDocumentUrlList(**acknowledgement_tool_kw)
self.assertFalse(event.getRelativeUrl() in document_url_list)
# validated document must be part of acknowledgements
portal.portal_workflow.doActionFor(event, 'start_action')
self.assertEqual(event.getSimulationState(), 'started')
self.tic()
document_url_list = portal.portal_acknowledgements\ document_url_list = portal.portal_acknowledgements\
.getUnreadDocumentUrlList(**acknowledgement_tool_kw) .getUnreadDocumentUrlList(**acknowledgement_tool_kw)
self.assertTrue(event.getRelativeUrl() in document_url_list) self.assertTrue(event.getRelativeUrl() in document_url_list)
......
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