Commit 9d5ba7e7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_rss_style: Rework WebSection_getEventList

  Rename Base_getEventList to WebSection_getEventList since we only expect Web Section as context
  No need specific script to get Titcket Url (merged into WebSection_getEventList)
  No need Folder_getOpenTicketList features, since the will be a single use case for all tickets
  Update tests to follow up the changes.
parent 55d30e75
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>list_lines=50, follow_up_portal_type=None, context_related=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getEventList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
web_site = context.getWebSiteValue()
if not web_site:
web_site = context.getPortalObject()
return web_site.absolute_url() + "/#/" + context.getRelativeUrl()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getTicketUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
return context.Base_getEventList(
list_lines=list_lines,
follow_up_portal_type=context.getVisibleAllowedContentTypeList(),
**kw)
...@@ -7,8 +7,12 @@ portal = context.getPortalObject() ...@@ -7,8 +7,12 @@ portal = context.getPortalObject()
# for safety, we limit at 100 lines # for safety, we limit at 100 lines
list_lines = min(list_lines, 100) list_lines = min(list_lines, 100)
web_site = context.getWebSiteValue()
if not web_site:
web_site = context.getPortalObject()
getTicket_memo = {} getTicket_memo = {}
def getTicketInfo(event): def getTicketInfo(event, web_site):
follow_up = event.getFollowUp() follow_up = event.getFollowUp()
try: try:
return getTicket_memo[follow_up] return getTicket_memo[follow_up]
...@@ -21,31 +25,19 @@ def getTicketInfo(event): ...@@ -21,31 +25,19 @@ def getTicketInfo(event):
getTicket_memo[follow_up] = ( getTicket_memo[follow_up] = (
ticket.getTitle(), ticket.getTitle(),
ticket.getResourceTranslatedTitle() or '', ticket.getResourceTranslatedTitle() or '',
ticket.Base_getTicketUrl(), web_site.absolute_url() + "/#/" + ticket.getRelativeUrl(),
) )
return getTicket_memo[follow_up] return getTicket_memo[follow_up]
if follow_up_portal_type is None: follow_up_portal_type = ['Support Request', 'Regularisation Request',
follow_up_portal_type = ['Support Request', 'Regularisation Request',
'Upgrade Decision', 'Subscription Request'] 'Upgrade Decision', 'Subscription Request']
ticket_simulation_state = [ follow_up_simulation_state = [
'validated','submitted', 'suspended', 'invalidated', 'validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states. # Unfortunally Upgrade decision uses diferent states.
'confirmed', 'started', 'stopped', 'delivered' 'confirmed', 'started', 'stopped', 'delivered'
] ]
context_kw = {}
if context_related:
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
)] or [-1]
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(),
...@@ -56,12 +48,13 @@ for brain in portal.portal_simulation.getMovementHistoryList( ...@@ -56,12 +48,13 @@ for brain in portal.portal_simulation.getMovementHistoryList(
limit=list_lines, limit=list_lines,
sort_on=(('stock.date', 'desc'), sort_on=(('stock.date', 'desc'),
('uid', 'desc')), ('uid', 'desc')),
**context_kw): follow_up__simulation_state=follow_up_simulation_state,
follow_up__portal_type=follow_up_portal_type):
event = brain.getObject() event = brain.getObject()
(ticket_title, (ticket_title,
ticket_category, ticket_category,
ticket_link) = getTicketInfo(event) ticket_link) = getTicketInfo(event, web_site)
data_list.append( data_list.append(
Object(**{ Object(**{
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Folder_getOpenTicketList</string> </value> <value> <string>WebSection_getEventList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -261,7 +261,7 @@ ...@@ -261,7 +261,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>method_name</string> </key>
<value> <string>Base_getEventList</string> </value> <value> <string>WebSection_getEventList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
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