Commit 86a5c7c1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_rss_style: reimplement Compute Node/Instance Tree RSS

  In order to use getMovementHistoryList too
parent 7cbb2bf6
"""Returns all ticket related events for RSS from a given module
"""
from Products.PythonScripts.standard import Object
portal = context.getPortalObject()
# for safety, we limit at 100 lines
list_lines = min(list_lines, 100)
getTicket_memo = {}
def getTicketInfo(event):
follow_up = event.getFollowUp()
try:
return getTicket_memo[follow_up]
except KeyError:
ticket = portal.restrictedTraverse(follow_up, None)
if ticket is None:
# For corner cases where user has an event for which he cannot access the ticket,
# we don't raise error so that others events are visible.
return event.getTitle(), '', ''
getTicket_memo[follow_up] = (
ticket.getTitle(),
ticket.getResourceTranslatedTitle() or '',
ticket.Base_getTicketUrl(),
)
return getTicket_memo[follow_up]
data_list = []
for brain in portal.portal_simulation.getMovementHistoryList(
security_query=portal.portal_catalog.getSecurityQuery(),
# Limit only to listable portal types
portal_type=['Web Message', 'Mail Nessage'],
follow_up_default_or_child_aggregate_uid=context.getUid(),
follow_up_simulation_state = ['validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states.
'confirmed', 'started', 'stopped', 'delivered'],
only_accountable=False,
# Only query by portal types of the module
follow_up_portal_type=["Support Request", "Upgrade Decision"],
omit_input=True,
simulation_state=('started', 'stopped', 'delivered'),
limit=list_lines,
sort_on=(('stock.date', 'desc'),
('uid', 'desc')),):
event = brain.getObject()
(ticket_title,
ticket_category,
ticket_link) = getTicketInfo(event)
data_list.append(
Object(**{
'title': ticket_title,
'category': ticket_category,
'author': brain.node_title,
'link': ticket_link,
'description': event.Event_getRSSTextContent(),
'pubDate': brain.date,
'guid': '{}-{}'.format(
event.getFollowUp(),
event.getRelativeUrl()),
'thumbnail': ( None)
})
)
return data_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>list_lines=50, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getTicketRelatedEventList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -79,11 +83,7 @@ ...@@ -79,11 +83,7 @@
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <value>
<list> <list/>
<string>listbox_modification_date</string>
<string>listbox_title</string>
<string>listbox_description</string>
</list>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>name</string> </key>
<value> <string>WebSection_viewRssFeedRender</string> </value> <value> <string>ComputeNode_view</string> </value>
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>View user rss feed list</string> </value> <value> <string>Ticket List</string> </value>
</item> </item>
<item> <item>
<key> <string>unicode_mode</string> </key> <key> <string>unicode_mode</string> </key>
......
...@@ -128,11 +128,11 @@ ...@@ -128,11 +128,11 @@
<string>Title</string> <string>Title</string>
</tuple> </tuple>
<tuple> <tuple>
<string>Ticket_getRSSGuid</string> <string>guid</string>
<string>guid</string> <string>guid</string>
</tuple> </tuple>
<tuple> <tuple>
<string>modification_date</string> <string>pubDate</string>
<string>pubDate</string> <string>pubDate</string>
</tuple> </tuple>
<tuple> <tuple>
...@@ -140,8 +140,16 @@ ...@@ -140,8 +140,16 @@
<string>Description</string> <string>Description</string>
</tuple> </tuple>
<tuple> <tuple>
<string>Base_getTicketUrl</string>
<string>link</string> <string>link</string>
<string>link</string>
</tuple>
<tuple>
<string>author</string>
<string>author</string>
</tuple>
<tuple>
<string>thumbnail</string>
<string>thumbnail</string>
</tuple> </tuple>
</list> </list>
</value> </value>
...@@ -159,20 +167,7 @@ ...@@ -159,20 +167,7 @@
<item> <item>
<key> <string>editable_columns</string> </key> <key> <string>editable_columns</string> </key>
<value> <value>
<list> <list/>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>modification_date</string>
<string>modification_date</string>
</tuple>
<tuple>
<string>description</string>
<string>description</string>
</tuple>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -251,7 +246,7 @@ ...@@ -251,7 +246,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>method_name</string> </key>
<value> <string>Base_getOpenRelatedTicketList</string> </value> <value> <string>WebSection_getUserTicketList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -79,11 +83,7 @@ ...@@ -79,11 +83,7 @@
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <value>
<list> <list/>
<string>listbox_modification_date</string>
<string>listbox_title</string>
<string>listbox_description</string>
</list>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>name</string> </key>
<value> <string>WebSection_viewRssFeedRender</string> </value> <value> <string>InstanceTree_view</string> </value>
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>View user rss feed list</string> </value> <value> <string>Ticket List</string> </value>
</item> </item>
<item> <item>
<key> <string>unicode_mode</string> </key> <key> <string>unicode_mode</string> </key>
......
...@@ -128,11 +128,11 @@ ...@@ -128,11 +128,11 @@
<string>Title</string> <string>Title</string>
</tuple> </tuple>
<tuple> <tuple>
<string>Ticket_getRSSGuid</string> <string>guid</string>
<string>guid</string> <string>guid</string>
</tuple> </tuple>
<tuple> <tuple>
<string>modification_date</string> <string>pubDate</string>
<string>pubDate</string> <string>pubDate</string>
</tuple> </tuple>
<tuple> <tuple>
...@@ -140,8 +140,16 @@ ...@@ -140,8 +140,16 @@
<string>Description</string> <string>Description</string>
</tuple> </tuple>
<tuple> <tuple>
<string>Base_getTicketUrl</string>
<string>link</string> <string>link</string>
<string>link</string>
</tuple>
<tuple>
<string>author</string>
<string>author</string>
</tuple>
<tuple>
<string>thumbnail</string>
<string>thumbnail</string>
</tuple> </tuple>
</list> </list>
</value> </value>
...@@ -159,20 +167,7 @@ ...@@ -159,20 +167,7 @@
<item> <item>
<key> <string>editable_columns</string> </key> <key> <string>editable_columns</string> </key>
<value> <value>
<list> <list/>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>modification_date</string>
<string>modification_date</string>
</tuple>
<tuple>
<string>description</string>
<string>description</string>
</tuple>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -251,7 +246,7 @@ ...@@ -251,7 +246,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>method_name</string> </key>
<value> <string>Base_getOpenRelatedTicketList</string> </value> <value> <string>Base_getTicketRelatedEventList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>method_name</string> </key>
<value> <string>WebSection_getUserTicketList</string> </value> <value> <string>Base_getTicketRelatedEventList</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