Commit b3c1dbe7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_web: Unify Web View and RSS scripts to query Tickets

Rename Test Name to reflect more to the actuall content.
Remove code duplication to keep implementation clean.
parent 66f8be9b
......@@ -17,7 +17,7 @@
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_hosting</skin_folder>
<skin_selection>Hosting</skin_selection>
<skin_selection>Hosting,RSS</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_hosting_theme</skin_folder>
......
"""
Keep a custom script for permit render other times of documents, ie.: Software Installation.
"""
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject()
query = ComplexQuery(
ComplexQuery(
SimpleQuery(portal_type="Support Request"),
SimpleQuery(default_source_project_uid=context.getUid()),
logical_operator='and'),
ComplexQuery(
SimpleQuery(portal_type="Upgrade Decision Line"),
SimpleQuery(default_aggregate_uid=context.getUid()),
logical_operator='and'),
logical_operator='or')
# Use event modification date instead.
kw['sort_on'] = [('modification_date', 'DESC'),]
kw['simulation_state'] = "NOT cancelled"
result_list = []
for document in portal.portal_catalog(query=query, **kw):
if document.getPortalType() == "Upgrade Decision Line":
result_list.append(document.getParentValue())
continue
result_list.append(document)
return result_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<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>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_getUserRssEntryList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -243,7 +243,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Computer_getUserRssEntryList</string> </value>
<value> <string>Base_getOpenRelatedTicketList</string> </value>
</item>
</dictionary>
</pickle>
......
"""
Keep a custom script for permit render other times of documents, ie.: Software Installation.
"""
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject()
query = ComplexQuery(
ComplexQuery(
SimpleQuery(portal_type="Support Request"),
SimpleQuery(default_source_project_uid=context.getUid()),
logical_operator='and'),
ComplexQuery(
SimpleQuery(portal_type="Upgrade Decision Line"),
SimpleQuery(default_aggregate_uid=context.getUid()),
logical_operator='and'),
logical_operator='or')
# Use event modification date instead.
kw['sort_on'] = [('modification_date', 'DESC'),]
kw['simulation_state'] = "NOT cancelled"
result_list = []
for document in portal.portal_catalog(query=query, **kw):
if document.getPortalType() == "Upgrade Decision Line":
result_list.append(document.getParentValue())
continue
result_list.append(document)
return result_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<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>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_getUserRssEntryList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -243,7 +243,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>HostingSubscription_getUserRssEntryList</string> </value>
<value> <string>Base_getOpenRelatedTicketList</string> </value>
</item>
</dictionary>
</pickle>
......
portal = context.getPortalObject()
kw['portal_type'] = ["Support Request", "Regularisation Request", "Upgrade Decision"]
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()
if person:
kw['simulation_state'] = "NOT cancelled"
kw['default_destination_decision_uid'] = person.getUid()
kw['sort_on'] = [('modification_date', 'DESC'),]
return context.getPortalObject().portal_catalog( **kw)
else:
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<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>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getUserRssTicketList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -243,7 +243,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>WebSection_getUserRssTicketList</string> </value>
<value> <string>WebSection_getUserTicketList</string> </value>
</item>
</dictionary>
</pickle>
......
return context.WebSection_getUserTicketList(**kw)
"""
Keep a custom script for permit render other times of documents, ie.: Software Installation.
"""
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject()
query = ComplexQuery(
ComplexQuery(
SimpleQuery(portal_type="Support Request"),
SimpleQuery(default_source_project_uid=context.getUid()),
logical_operator='and'),
ComplexQuery(
SimpleQuery(portal_type="Upgrade Decision Line"),
SimpleQuery(default_aggregate_uid=context.getUid()),
logical_operator='and'),
logical_operator='or')
# Use event modification date instead.
kw['sort_on'] = [('modification_date', 'DESC'),]
kw['simulation_state'] = "NOT cancelled"
result_list = []
for document in portal.portal_catalog(query=query, **kw):
if document.getPortalType() == "Upgrade Decision Line":
result_list.append(document.getParentValue())
continue
result_list.append(document)
return result_list
......@@ -5,19 +5,22 @@ support_in_progress_url = context.REQUEST.get('new_support_request', '')
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()
if person:
kw['default_destination_decision_uid'] = person.getUid()
kw['simulation_state'] = "NOT cancelled"
kw['sort_on'] = [('modification_date', 'DESC'),]
found = False
support_request_list = []
for support_request in context.getPortalObject().portal_catalog(**kw):
if support_in_progress_url and \
support_request.getRelativeUrl() == support_in_progress_url:
found = True
support_request_list.append(support_request.getObject())
if support_in_progress_url and not found:
support_in_progress = portal.restrictedTraverse(
if not support_in_progress_url:
return portal.portal_catalog(**kw)
support_in_progress = portal.restrictedTraverse(
support_in_progress_url, None)
if support_in_progress and support_in_progress.getDestinationDecisionUid() == person.getUid():
support_request_list.insert(0, support_in_progress)
kw['uid'] = "NOT %s" % support_in_progress.getUid()
support_request_list = portal.portal_catalog(**kw)
if support_in_progress and \
support_in_progress.getDestinationDecisionUid() == person.getUid():
support_request_list = list(portal.portal_catalog(**kw))
support_request_list.insert(0, support_in_progress)
return support_request_list
else:
......
......@@ -35,11 +35,7 @@ import time
from DateTime import DateTime
class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin,
SecurityTestCase):
#def beforeTearDown(self):
# transaction.abort()
class SlapOSWebMixin(testSlapOSMixin, SecurityTestCase):
def createPerson(self):
person_user = self.portal.person_module.template_member.\
......@@ -167,13 +163,9 @@ class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin,
self.cancelled_regularisation_request.cancel()
self.tic()
self.login(self.person.getReference())
self.changeSkin("RSS")
def test_WebSection_getUserRssTicketList(self):
""" Test get User RSS """
ticket_list = self.portal.WebSection_getUserRssTicketList()
def _test_WebSection_getUserTicketList(self):
ticket_list = self.portal.WebSection_getUserTicketList()
self.assertEquals(len(ticket_list), 5)
self.assertSameSet([i.getUid() for i in ticket_list],
[self.support_request.getUid(),
......@@ -182,7 +174,79 @@ class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin,
self.hs_support_request.getUid(),
self.hs_upgrade_decision.getUid()])
def _test_Base_getOpenRelatedTicketList_computer(self):
""" Test get Computer RSS """
self.login()
ticket_list = self.computer.Base_getOpenRelatedTicketList()
self.assertSameSet([i.getRelativeUrl() for i in ticket_list],
[self.support_request.getRelativeUrl(),
self.upgrade_decision.getRelativeUrl()])
self.assertEquals(len(ticket_list), 2)
def _test_Base_getOpenRelatedTicketList_hosting_subscription(self):
""" Test get Hosting Subscription RSS """
self.login()
ticket_list = self.hosting_subscription.Base_getOpenRelatedTicketList()
self.assertSameSet([i.getRelativeUrl() for i in ticket_list],
[self.hs_support_request.getRelativeUrl(),
self.hs_upgrade_decision.getRelativeUrl()])
self.assertEquals(len(ticket_list), 2)
class TestSlapOSWebSkin(SlapOSWebMixin):
def afterSetUp(self):
super(TestSlapOSWebSkin, self).afterSetUp()
self.login(self.person.getReference())
self.changeSkin("Hosting")
def test_WebSection_getUserTicketList(self):
""" Test get User Tickers at Hosting Skin"""
self._test_WebSection_getUserTicketList()
def test_WebSection_getUserTicketList_new_support_request(self):
""" Test get User Tickers at Hosting Skin with new support request """
self._test_WebSection_getUserTicketList()
try:
sr = self.portal.support_request_module.newContent(\
title="Test Support Request %s" % self.new_id,
resource="service_module/slapos_crm_monitoring",
destination_decision_value=self.person)
self.portal.REQUEST.set("new_support_request", sr.getRelativeUrl())
ticket_list = self.portal.WebSection_getUserTicketList()
self.assertEquals(len(ticket_list), 6)
self.assertSameSet([i.getUid() for i in ticket_list],
[self.support_request.getUid(),
self.upgrade_decision.getUid(),
self.regularisation_request.getUid(),
self.hs_support_request.getUid(),
self.hs_upgrade_decision.getUid(),
sr.getUid()])
self.assertEquals(ticket_list[0].getUid(), sr.getUid())
finally:
transaction.abort()
def test_Base_getOpenRelatedTicketList_computer(self):
""" Test Base_getOpenRelatedTicketList with Hosting Subscriptions on Hosting
"""
self._test_Base_getOpenRelatedTicketList_computer()
def test_Base_getOpenRelatedTicketList_hosting_subscription(self):
""" Test Base_getOpenRelatedTicketList with Computer on Hosting
"""
self._test_Base_getOpenRelatedTicketList_hosting_subscription()
class TestSlapOSRSSSkin(SlapOSWebMixin):
def afterSetUp(self):
super(TestSlapOSRSSSkin, self).afterSetUp()
self.login(self.person.getReference())
self.changeSkin("RSS")
def test_WebSection_getUserTicketList(self):
""" Test get User Tickers at RSS Skin"""
self._test_WebSection_getUserTicketList()
def _test_WebSection_getRSSContent(self, ticket):
""" Test for get Date and Content for the RSS Feed
......@@ -248,41 +312,26 @@ class TestSlapOSPerson_checkToCreateRegularisationRequest(testSlapOSMixin,
ticket.WebSection_getRSSDateContent())
def test_WebSection_getRSSContents_support_request(self):
""" Test for get Date and Content for the RSS Feed for
Support Request
""" Test for get Date and Content for the RSS Feed for Support Request
"""
self._test_WebSection_getRSSContent(self.support_request)
def test_WebSection_getRSSContents_upgrade_decision(self):
""" Test for get Date and Content for the RSS Feed for
Upgrade Decision
""" Test for get Date and Content for the RSS Feed for Upgrade Decision
"""
self._test_WebSection_getRSSContent(self.upgrade_decision)
def test_WebSection_getRSSContents_regularisation_request(self):
""" Test for get Date and Content for the RSS Feed for
Upgrade Decision
""" Test for get Date + Content for the RSS Feed for Regularisation Request
"""
self._test_WebSection_getRSSContent(self.regularisation_request)
def test_Computer_getUserRssEntryList(self):
""" Test get Computerr RSS """
self.login()
ticket_list = self.computer.Computer_getUserRssEntryList()
self.assertSameSet([i.getRelativeUrl() for i in ticket_list],
[self.support_request.getRelativeUrl(),
self.upgrade_decision.getRelativeUrl()])
self.assertEquals(len(ticket_list), 2)
def test_Base_getOpenRelatedTicketList_computer(self):
""" Test Base_getOpenRelatedTicketList with Computer on RSS """
self._test_Base_getOpenRelatedTicketList_computer()
def test_HostingSubscription_getUserRssEntryList(self):
""" Test get Hosting Subscription RSS """
self.login()
ticket_list = self.hosting_subscription.HostingSubscription_getUserRssEntryList()
self.assertSameSet([i.getRelativeUrl() for i in ticket_list],
[self.hs_support_request.getRelativeUrl(),
self.hs_upgrade_decision.getRelativeUrl()])
self.assertEquals(len(ticket_list), 2)
def test_Base_getOpenRelatedTicketList_hosting_subscription(self):
""" Test Base_getOpenRelatedTicketList with Hosting Subscriptions on RSS """
self._test_Base_getOpenRelatedTicketList_hosting_subscription()
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSRSSSkins</string> </value>
<value> <string>testSlapOSWebSkins</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -24,7 +24,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSRSSSkins</string> </value>
<value> <string>test.erp5.testSlapOSWebSkins</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -3,6 +3,7 @@ erp5_km_theme | Hosting
erp5_xhtml_style | Hosting
slapos_rss | RSS
vifib_hosting | Hosting
vifib_hosting | RSS
vifib_hosting_theme | Hosting
vifib_jauks_theme | Hosting
vifib_jauks_widget_library | Hosting
......
test.erp5.testSlapOSRSSSkins
\ No newline at end of file
test.erp5.testSlapOSWebSkins
\ No newline at end of file
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