Commit 1d7e6f8a authored by Romain Courteaud's avatar Romain Courteaud

slapos_rss_style: fix context_related parameter usage

parent 2e53e3f9
...@@ -27,20 +27,29 @@ def getTicketInfo(event): ...@@ -27,20 +27,29 @@ def getTicketInfo(event):
if follow_up_portal_type is None: if follow_up_portal_type is None:
follow_up_portal_type = ['Support Request', 'Regularisation Request', 'Upgrade Decision'] follow_up_portal_type = ['Support Request', 'Regularisation Request', 'Upgrade Decision']
ticket_simulation_state = [
'validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states.
'confirmed', 'started', 'stopped', 'delivered'
]
context_kw = {} context_kw = {}
if context_related: if context_related:
context_kw['follow_up__uid'] = context.getUid() context_kw['follow_up__uid'] = [x.getUid() for x in portal.portal_catalog(
causality__uid=context.getUid(),
portal_type=follow_up_portal_type,
simulation_state=ticket_simulation_state
)]
else:
context_kw['follow_up__simulation_state'] = ticket_simulation_state
context_kw['follow_up__portal_type'] = follow_up_portal_type,
data_list = [] data_list = []
for brain in portal.portal_simulation.getMovementHistoryList( for brain in portal.portal_simulation.getMovementHistoryList(
security_query=portal.portal_catalog.getSecurityQuery(), security_query=portal.portal_catalog.getSecurityQuery(),
# Limit only to listable portal types # Limit only to listable portal types
portal_type=['Web Message', 'Mail Message'], portal_type=['Web Message', 'Mail Message'],
follow_up__simulation_state = ['validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states.
'confirmed', 'started', 'stopped', 'delivered'],
only_accountable=False, only_accountable=False,
follow_up__portal_type=follow_up_portal_type,
simulation_state=('started', 'stopped', 'delivered'), simulation_state=('started', 'stopped', 'delivered'),
limit=list_lines, limit=list_lines,
sort_on=(('stock.date', 'desc'), sort_on=(('stock.date', 'desc'),
......
...@@ -65,7 +65,8 @@ class TestRSSSyleSkinsMixin(SlapOSTestCaseMixinWithAbort): ...@@ -65,7 +65,8 @@ class TestRSSSyleSkinsMixin(SlapOSTestCaseMixinWithAbort):
instance_tree.edit( instance_tree.edit(
title= "Test hosting sub ticket %s" % new_id, title= "Test hosting sub ticket %s" % new_id,
reference="TESTHST-%s" % new_id, reference="TESTHST-%s" % new_id,
destination_section_value=person destination_section_value=person,
follow_up_value=self.addProject()
) )
return instance_tree return instance_tree
...@@ -316,10 +317,9 @@ class TestSlapOSFolder_getOpenTicketList(TestRSSSyleSkinsMixin): ...@@ -316,10 +317,9 @@ class TestSlapOSFolder_getOpenTicketList(TestRSSSyleSkinsMixin):
self.portal.portal_skins.changeSkin('RSS') self.portal.portal_skins.changeSkin('RSS')
return sr return sr
project = self.addProject()
person = self.makePerson(self.addProject(), index=1, user=1) person = self.makePerson(project, index=1, user=1)
person.newContent(portal_type="Assignment", self.addProjectProductionManagerAssignment(person, project)
group="company").open()
self.tic() self.tic()
self.portal.portal_skins.changeSkin('RSS') self.portal.portal_skins.changeSkin('RSS')
...@@ -436,23 +436,26 @@ class TestSlapOSFolder_getOpenTicketList(TestRSSSyleSkinsMixin): ...@@ -436,23 +436,26 @@ class TestSlapOSFolder_getOpenTicketList(TestRSSSyleSkinsMixin):
class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin): class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin):
def newSupportRequest(self): def newSupportRequest(self, causality_value):
self.portal.portal_skins.changeSkin('View') self.portal.portal_skins.changeSkin('View')
person = self.makePerson(self.addProject()) person = self.makePerson(self.addProject())
sr = self.portal.support_request_module.newContent(\ support_request = person.Entity_createTicketFromTradeCondition(
title="Test Support Request %s" % self.new_id) 'service_module/slapos_crm_monitoring',
event = self.portal.event_module.newContent( "Test Support Request %s" % self.new_id,
portal_type='Web Message', '',
follow_up_value=sr, causality=causality_value.getRelativeUrl(),
source_project=causality_value.getFollowUp()
)
support_request.Ticket_createProjectEvent(
support_request.getTitle(), 'incoming', 'Web Message',
support_request.getResource(),
text_content="Test Support Request %s" % self.new_id, text_content="Test Support Request %s" % self.new_id,
start_date = DateTime(), content_type='text/plain',
source_value=person, source=person.getRelativeUrl()
#destination_value=self.portal.organisation_module.slapos,
resource_value=self.portal.service_module.slapos_crm_monitoring
) )
event.start()
self.tic() self.tic()
return sr return support_request
def test_getTicketRelatedEventList_support_request_related_to_compute_node(self): def test_getTicketRelatedEventList_support_request_related_to_compute_node(self):
self._test_getTicketRelatedEventList_support_request_related( self._test_getTicketRelatedEventList_support_request_related(
...@@ -463,28 +466,16 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin): ...@@ -463,28 +466,16 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin):
self._makeInstanceTree()) self._makeInstanceTree())
def _test_getTicketRelatedEventList_support_request_related(self, document): def _test_getTicketRelatedEventList_support_request_related(self, document):
ticket = self.newSupportRequest() ticket = self.newSupportRequest(document)
ticket.setAggregateValue(document)
event = ticket.getFollowUpRelatedValue() event = ticket.getFollowUpRelatedValue()
person = self.makePerson(self.addProject(), index=1, user=1) person = self.makePerson(self.addProject(), index=1, user=1)
person.newContent(portal_type="Assignment", self.addProjectProductionManagerAssignment(person, document.getFollowUpValue())
group="company").open()
self.tic() self.tic()
self.portal.portal_skins.changeSkin('RSS') self.portal.portal_skins.changeSkin('RSS')
self.login(person.getUserId()) self.login(person.getUserId())
open_related_ticket_list = document.Base_getTicketRelatedEventList()
# Not indexed yet
self.assertEqual(len(open_related_ticket_list), 0)
self.tic()
self.portal.portal_skins.changeSkin('RSS')
open_related_ticket_list = document.Base_getTicketRelatedEventList()
self.assertEqual(len(open_related_ticket_list), 0)
ticket.submit()
self.tic() self.tic()
open_related_ticket_list = document.Base_getTicketRelatedEventList() open_related_ticket_list = document.Base_getTicketRelatedEventList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
...@@ -494,6 +485,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin): ...@@ -494,6 +485,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin):
event.getRelativeUrl())) event.getRelativeUrl()))
ticket.validate() ticket.validate()
self.tic() self.tic()
self.portal.portal_skins.changeSkin('RSS')
open_related_ticket_list = document.Base_getTicketRelatedEventList() open_related_ticket_list = document.Base_getTicketRelatedEventList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertNotEqual(open_related_ticket_list[0].pubDate, None) self.assertNotEqual(open_related_ticket_list[0].pubDate, None)
...@@ -502,6 +494,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin): ...@@ -502,6 +494,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin):
event.getRelativeUrl())) event.getRelativeUrl()))
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self.portal.portal_skins.changeSkin('RSS')
open_related_ticket_list = document.Base_getTicketRelatedEventList() open_related_ticket_list = document.Base_getTicketRelatedEventList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertNotEqual(open_related_ticket_list[0].pubDate, None) self.assertNotEqual(open_related_ticket_list[0].pubDate, None)
...@@ -511,6 +504,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin): ...@@ -511,6 +504,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin):
ticket.invalidate() ticket.invalidate()
self.tic() self.tic()
self.portal.portal_skins.changeSkin('RSS')
open_related_ticket_list = document.Base_getTicketRelatedEventList() open_related_ticket_list = document.Base_getTicketRelatedEventList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 1)
self.assertNotEqual(open_related_ticket_list[0].pubDate, None) self.assertNotEqual(open_related_ticket_list[0].pubDate, None)
...@@ -532,8 +526,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin): ...@@ -532,8 +526,7 @@ class TestSlapOSBase_getTicketRelatedEventList(TestRSSSyleSkinsMixin):
def _test_getTicketRelatedEventList_cancelled_support_request_related(self, document): def _test_getTicketRelatedEventList_cancelled_support_request_related(self, document):
ticket = self.newSupportRequest() ticket = self.newSupportRequest(document)
ticket.setAggregateValue(document)
event = ticket.getFollowUpRelatedValue() event = ticket.getFollowUpRelatedValue()
person = self.makePerson(self.addProject(), index=1, user=1) person = self.makePerson(self.addProject(), index=1, user=1)
person.newContent(portal_type="Assignment", person.newContent(portal_type="Assignment",
......
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