Commit f324043a authored by Guillaume Hervier's avatar Guillaume Hervier Committed by Thomas Gambier

Add/Fix URL columns on some views

I added and fixed some URL columns on some views:
- `slapos_cloud/ComputerUsage_view`
- `slapos_cloud/HostingSubscription_view`

The goal is to make the process to look for the needed informations faster by reducing clicks between views on listbox objects, by making some changes such as clicking on an object name on a column should redirect to the object view page instead of the row's object view page.

Additionally, these changes are made to be compatible with the RenderJS UI.

As this is not the default behaviour in ERP5, it may sound counter-intuitive, but this special behaviour is made to improve efficiency/productivity over intuitivity.

Personally, I wondered about having some "compromise" which is having the "Plane" icon on these columns beside the content to clearly indicate that this icon will redirect to the object's view (as the current "Plane icon" behaviour in ERP5)

/reviewed-on !89
parents b8d5e234 cb1e6dd7
partition = context
if brain is None:
brain = context
software_instance_list = partition.getAggregateRelatedValueList(portal_type=["Software Instance"])
for si in software_instance_list:
obj = si.getObject()
hosting_url = obj.getSpecialise()
if hosting_url:
return "%s?editable_mode:int=1" % hosting_url
software_instance = brain.getAggregateRelatedValue(portal_type=["Software Instance"])
if software_instance is None:
return None
hosting_subscription = software_instance.getSpecialiseValue()
if url_dict: # If RenderJS UI
jio_key = hosting_subscription.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return hosting_subscription.absolute_url()
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
<value> <string>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
partition = context
if brain is None:
brain = context
software_instance_list = partition.getAggregateRelatedValueList(portal_type=["Software Instance"])
for si in software_instance_list:
obj = si.getObject()
return "%s?editable_mode:int=1" % obj.getRelativeUrl()
software_instance = brain.getAggregateRelatedValue(portal_type=["Software Instance"])
if software_instance is None:
return None
if url_dict: # If RenderJS UI
jio_key = software_instance.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
'editable': 'true',
},
'options': {
'jio_key': jio_key
},
}
else:
return software_instance.absolute_url()
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
<value> <string>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
partition = context
si = partition.getAggregateRelatedValue(portal_type=["Software Instance", "Slave Instance"])
if si:
person = si.getSpecialiseValue().getDestinationSectionValue()
return '<a href="%s?editable_mode:int=1">%s</a>' % (person.getRelativeUrl(), person.getTitle())
instance = context.getAggregateRelatedValue(portal_type=["Software Instance"])
if instance is None:
return None
owner = instance.getSpecialiseValue().getDestinationSectionValue()
return owner.getTitle()
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputerPartition_getOwnerAsHtml</string> </value>
<value> <string>ComputerPartition_getOwnerName</string> </value>
</item>
</dictionary>
</pickle>
......
if brain is None:
brain = context
instance = brain.getAggregateRelatedValue(portal_type=["Software Instance"])
if instance is None:
return None
owner = instance.getSpecialiseValue().getDestinationSectionValue()
if url_dict: # If RenderJS UI
jio_key = owner.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return owner.absolute_url()
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
<value> <string>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputerPartition_getUsageReportUrl</string> </value>
<value> <string>ComputerPartition_getOwnerUrl</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -95,7 +95,6 @@
<string>listbox_usage</string>
<string>my_busy_computer_partition_list_creation_date</string>
<string>my_busy_computer_partition_list_status</string>
<string>my_busy_computer_partition_list_owner_title</string>
<string>listbox_installation_status</string>
<string>my_busy_computer_partition_list_hosting_subscription_title</string>
<string>my_busy_computer_partition_list_instance_title</string>
......
......@@ -414,7 +414,7 @@
<string>Image</string>
</tuple>
<tuple>
<string>owner_title</string>
<string>ComputerPartition_getOwnerName</string>
<string>Owner</string>
</tuple>
<tuple>
......@@ -641,10 +641,6 @@
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>reference</string>
<string>ComputerPartition_getUsageReportUrl</string>
</tuple>
<tuple>
<string>instance_title</string>
<string>ComputerPartition_getInstanceUrlString</string>
......@@ -661,6 +657,10 @@
<string>image</string>
<string>ComputerPartition_getInstanceUrlString</string>
</tuple>
<tuple>
<string>ComputerPartition_getOwnerName</string>
<string>ComputerPartition_getOwnerUrl</string>
</tuple>
<tuple>
<string>ComputerPartition_getLastestContactedDate</string>
<string>ComputerPartition_getInstanceUrlString</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>default</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_busy_computer_partition_list_owner_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_editor_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Instance Owner</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/ComputerPartition_getOwnerAsHtml</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -95,9 +95,7 @@
<value>
<list>
<string>listbox_aggregate_parent_title</string>
<string>listbox_aggregate_default_ipv6</string>
<string>listbox_is_slave</string>
<string>listbox_aggregate_parent_reference</string>
</list>
</value>
</item>
......@@ -108,6 +106,7 @@
<string>my_title</string>
<string>my_reference</string>
<string>my_source_reference</string>
<string>listbox_aggregate_parent_reference</string>
</list>
</value>
</item>
......
......@@ -20,6 +20,7 @@
<string>search_columns</string>
<string>selection_name</string>
<string>title</string>
<string>url_columns</string>
</list>
</value>
</item>
......@@ -139,11 +140,11 @@
<string>Computer Ref.</string>
</tuple>
<tuple>
<string>getAggregateTitle</string>
<string>aggregate_title</string>
<string>Computer Partition</string>
</tuple>
<tuple>
<string>aggregate_default_ipv6</string>
<string>SoftwareInstance_getComputerPartitionIPv6</string>
<string>IPv6</string>
</tuple>
<tuple>
......@@ -228,6 +229,25 @@
<key> <string>title</string> </key>
<value> <string>Software Instances</string> </value>
</item>
<item>
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>aggregate_title</string>
<string>SoftwareInstance_getPartitionUrl</string>
</tuple>
<tuple>
<string>aggregate_parent_title</string>
<string>SoftwareInstance_getComputerUrl</string>
</tuple>
<tuple>
<string>aggregate_parent_reference</string>
<string>SoftwareInstance_getComputerUrl</string>
</tuple>
</list>
</value>
</item>
</dictionary>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StringField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_aggregate_default_ipv6</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>text</string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>IPv6</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/SoftwareInstance_getComputerPartitionIPv6</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if brain is None:
brain = context
partition = brain.getAggregateValue()
if partition is None:
return None
computer = partition.getParent()
if url_dict: # If RenderJS UI
jio_key = computer.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return computer.absolute_url()
<?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>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_getComputerUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# Script to generate URL for computer partiton of Software Instances
# both for XHTML UI as well as renderJS UI
if brain is None:
brain = context
# 'brain' in this case is the Software Instance, hence trying to get
# the partition as it it related to the Software Instance with 'aggregate'
# category, hence, this will get us the relative URL of the aggregate
partition = brain.getAggregateValue()
if partition is None:
return None
if url_dict: # if RenderJS UI
jio_key = partition.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return partition.absolute_url()
<?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>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_getPartitionUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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