Commit 66f8be9b authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_rss: Fix RSS Scripts and add unit tests

Several aspects were broken and not working.
Include Unit tests for the scripts as it was missing.
parent 97651fa6
""" """
Keep a custom script for permit render other times of documents, ie.: Software Installation. Keep a custom script for permit render other times of documents, ie.: Software Installation.
""" """
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject() portal = context.getPortalObject()
kw['portal_type'] = ["Support Request", "Upgrade Decision"]
# Source project is only set for Support Request, it don't work for query = ComplexQuery(
# Upgrade Decisions. ComplexQuery(
kw['source_project_uid'] = context.getUid() 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')
person = portal.ERP5Site_getAuthenticatedMemberPersonValue() # Use event modification date instead.
if person: kw['sort_on'] = [('modification_date', 'DESC'),]
kw['default_destination_decision_uid'] = person.getUid() kw['simulation_state'] = "NOT cancelled"
result_list = []
# Use event modification date instead. for document in portal.portal_catalog(query=query, **kw):
kw['sort_on'] = [('modification_date', 'DESC'),] if document.getPortalType() == "Upgrade Decision Line":
return context.getPortalObject().portal_catalog(**kw) result_list.append(document.getParentValue())
continue
else: result_list.append(document)
return [] return result_list
""" """
Keep a custom script for permit render other times of documents, ie.: Software Installation. Keep a custom script for permit render other times of documents, ie.: Software Installation.
""" """
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject() portal = context.getPortalObject()
kw['portal_type'] = ["Support Request", "Upgrade Decision"]
kw['source_project_uid'] = context.getUid()
person = portal.ERP5Site_getAuthenticatedMemberPersonValue() query = ComplexQuery(
if person: ComplexQuery(
kw['default_destination_decision_uid'] = person.getUid() 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. # Use event modification date instead.
kw['sort_on'] = [('modification_date', 'DESC'),] kw['sort_on'] = [('modification_date', 'DESC'),]
return context.getPortalObject().portal_catalog(**kw) kw['simulation_state'] = "NOT cancelled"
result_list = []
else: for document in portal.portal_catalog(query=query, **kw):
return [] if document.getPortalType() == "Upgrade Decision Line":
result_list.append(document.getParentValue())
continue
result_list.append(document)
return result_list
...@@ -2,10 +2,11 @@ portal = context.getPortalObject() ...@@ -2,10 +2,11 @@ portal = context.getPortalObject()
event = portal.portal_catalog.getResultValue( event = portal.portal_catalog.getResultValue(
follow_up_uid=context.getUid(), follow_up_uid=context.getUid(),
sort_on=[('delivery.start_date', 'DESC')], sort_on=[('modification_date', 'DESC')],
) )
if event: if event:
return event.getModificationDate() return event.getModificationDate()
else:
context.getModificationDate() return context.getModificationDate()
...@@ -2,10 +2,10 @@ portal = context.getPortalObject() ...@@ -2,10 +2,10 @@ portal = context.getPortalObject()
event = portal.portal_catalog.getResultValue( event = portal.portal_catalog.getResultValue(
follow_up_uid=context.getUid(), follow_up_uid=context.getUid(),
sort_on=[('delivery.start_date', 'DESC')], sort_on=[('modification_date', 'DESC')],
) )
if event: if event:
return event.getTextContent() return event.getTextContent()
else:
context.getDescription() return context.getDescription()
portal = context.getPortalObject() portal = context.getPortalObject()
kw['portal_type'] = ["Support Request", "Regularisation Request", "Upgrade Decision"] kw['portal_type'] = ["Support Request", "Regularisation Request", "Upgrade Decision"]
person = portal.ERP5Site_getAuthenticatedMemberPersonValue() person = portal.ERP5Site_getAuthenticatedMemberPersonValue()
if person: if person:
kw['simulation_state'] = "NOT cancelled"
kw['default_destination_decision_uid'] = person.getUid() kw['default_destination_decision_uid'] = person.getUid()
kw['sort_on'] = [('modification_date', 'DESC'),] kw['sort_on'] = [('modification_date', 'DESC'),]
return context.getPortalObject().portal_catalog(**kw) return context.getPortalObject().portal_catalog( **kw)
else: else:
return [] return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSRSSSkins</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSRSSSkins</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
test.erp5.testSlapOSRSSSkins
\ 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