Commit a41e32d8 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_rss_style: Clean up and drop duplication

   ... Unify scripts into Base_getEventList
parent 86a5c7c1
......@@ -24,19 +24,29 @@ def getTicketInfo(event):
)
return getTicket_memo[follow_up]
if follow_up_portal_type is None:
follow_up_portal_type = ['Support Request', 'Regularisation Request', 'Upgrade Decision']
context_kw = {}
if context_related:
context_kw['follow_up_default_or_child_aggregate_uid'] = context.getUid()
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_simulation_state="NOT cancelled",
follow_up_simulation_state = ['validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states.
'confirmed', 'started', 'stopped', 'delivered'],
only_accountable=False,
follow_up_portal_type=['Support Request', 'Regularisation Request', 'Upgrade Decision'],
follow_up_portal_type=follow_up_portal_type,
omit_input=True,
simulation_state=('started', 'stopped', 'delivered'),
limit=list_lines,
sort_on=(('stock.date', 'desc'),
('uid', 'desc')),):
('uid', 'desc')),
**context_kw):
event = brain.getObject()
(ticket_title,
ticket_category,
......
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<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>Event_getRSSTextContent</string> </value>
<value> <string>Base_getEventList</string> </value>
</item>
</dictionary>
</pickle>
......
"""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
return context.Base_getEventList(
list_lines=list_lines,
follow_up_portal_type=['Support Request', 'Upgrade Decision'],
context_related=True, **kw)
"""
Include information of the sender/recipient to clarify.
"""
return """
Sender: %s
Recipient: %s
Content:
%s
""" % (context.getSourceTitle(""),
",".join(context.getDestinationTitleList()),
context.getTextContent())
"""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_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
return context.Base_getEventList(
list_lines=list_lines,
follow_up_portal_type=context.getVisibleAllowedContentTypeList(),
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
context_related=False, **kw)
<?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>WebSection_getUserTicketList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -246,7 +246,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>WebSection_getUserTicketList</string> </value>
<value> <string>Base_getEventList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -246,7 +246,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Base_getTicketRelatedEventList</string> </value>
<value> <string>Base_getEventList</string> </value>
</item>
</dictionary>
</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