Commit 43d57bc8 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Make Ticket tab on Computer Node more universal

   Reuse Base_getOpenRelatedTicketList to query tickets consistently and extends original goal to also show Upgrade Decisions.

   This tab shows all Tickets related to the computer and to all instance trees that has one instance allocated on it (even if isn't the one that is failing).
parent 6f832dc6
......@@ -73,7 +73,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ComputeNode_viewRelatedSupportRequest</string> </value>
<value> <string>string:${object_url}/ComputeNode_viewTicketRelatedList</string> </value>
</item>
</dictionary>
</pickle>
......
"""
Keep a custom script for permit render other times of documents, ie.: Software Installation.
"""
portal = context.getPortalObject()
kw['portal_type'] = ["Support Request", "Upgrade Decision"]
kw['default_or_child_aggregate_uid'] = context.getUid()
if 'default_or_child_aggregate_uid' not in kw:
kw['default_or_child_aggregate_uid'] = context.getUid()
kw['sort_on'] = (('modification_date', 'DESC'),)
if 'simulation_state' not in kw:
kw['simulation_state'] = ['validated','submitted', 'suspended', 'invalidated',
......
portal = context.getPortalObject()
uid_list = [context.getUid()]
for instance in portal.portal_catalog(
portal_type="Software Instance",
default_aggregate_uid=[cp.uid for cp in context.searchFolder(portal_type="Compute Partition")]):
uid_list.append(instance.getSpecialiseUid(portal_type="Instance Tree"))
return portal.portal_catalog(
portal_type='Support Request',
default_aggregate_uid=uid_list,
**kw)
"""
Get all related tickets from the computer and everything that was allocated
on it.
"""
portal = context.getPortalObject()
uid_list = [context.getUid()]
computer_partition_uid_list = [
cp.getUid() for cp in context.contentValues(portal_type="Compute Partition") if cp.getSlapState() == 'busy']
for instance in portal.portal_catalog(
portal_type="Software Instance",
select_dict={'specialise_uid': None},
specialise_portal_type="Instance Tree",
default_aggregate_uid=computer_partition_uid_list):
if instance.specialise_uid not in uid_list:
uid_list.append(instance.specialise_uid)
kw['default_or_child_aggregate_uid'] = uid_list
return context.Base_getOpenRelatedTicketList(**kw)
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_getRelatedSupportRequestList</string> </value>
<value> <string>ComputeNode_getTicketRelatedList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -37,6 +37,10 @@
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
......@@ -105,7 +109,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_viewRelatedSupportRequest</string> </value>
<value> <string>ComputeNode_viewTicketRelatedList</string> </value>
</item>
<item>
<key> <string>method</string> </key>
......@@ -113,7 +117,7 @@
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebSection_viewMonitoringSupportRequestList</string> </value>
<value> <string>ComputeNode_viewTicketRelatedList</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
......@@ -129,7 +133,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View Monitoring Support Request List</string> </value>
<value> <string>Related Tickets</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
......
......@@ -122,6 +122,10 @@
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>portal_type</string>
<string>Portal Type</string>
</tuple>
<tuple>
<string>resource_title</string>
<string>Type</string>
......@@ -227,7 +231,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>ComputeNode_getRelatedSupportRequestList</string> </value>
<value> <string>ComputeNode_getTicketRelatedList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -10,12 +10,13 @@ from DateTime import DateTime
if context.getSimulationState() == "invalidated":
return "Closed Ticket"
document = context.getAggregateValue()
if context.getPortalType() != "Support Request":
return "Not a Support Request"
document = context.getAggregateValue()
if document is None:
return True
aggregate_portal_type = document.getPortalType()
if aggregate_portal_type == "Compute Node":
if document.getMonitorScope() == "disabled":
......
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