Commit 809dd9b3 authored by Rafael Monnerat's avatar Rafael Monnerat

Only show transfer action if the user is the owner

See merge request !546
parents faa2d3dc a70f8937
Pipeline #28788 failed with stage
in 0 seconds
...@@ -250,6 +250,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -250,6 +250,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_hal_json_style/Project_acceptInvitation', 'slapos_hal_json_style/Project_acceptInvitation',
'slapos_hal_json_style/Project_closeRelatedAssignment', 'slapos_hal_json_style/Project_closeRelatedAssignment',
'slapos_hal_json_style/Project_hasItem', 'slapos_hal_json_style/Project_hasItem',
'slapos_hal_json_style/Document_isRequesterOrOwner',
'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedInstanceTreeReportLineList', 'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedInstanceTreeReportLineList',
'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedPaymentTransactionIntegrationId', 'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedPaymentTransactionIntegrationId',
'slapos_hal_json_style/SoftwareInstallation_getSoftwareReleaseInformation', 'slapos_hal_json_style/SoftwareInstallation_getSoftwareReleaseInformation',
......
...@@ -404,10 +404,12 @@ ...@@ -404,10 +404,12 @@
request_certificate_url: url_list[3], request_certificate_url: url_list[3],
revoke_certificate_url: url_list[4], revoke_certificate_url: url_list[4],
rss_url: url_list[5], rss_url: url_list[5],
transfer_url: url_list[6],
selection_url: url_list[7], selection_url: url_list[7],
save_action: true save_action: true
}; };
if (gadget.state.doc.is_owner !== undefined) {
header_dict.transfer_url = url_list[6];
}
if (!gadget.state.editable) { if (!gadget.state.editable) {
header_dict.edit_content = url_list[0]; header_dict.edit_content = url_list[0];
} }
......
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.49947.49157.41540</string> </value> <value> <string>1008.51160.9059.61542</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1685554088.09</float> <float>1687464494.14</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -244,9 +244,11 @@ ...@@ -244,9 +244,11 @@
selection_url: url_list[1], selection_url: url_list[1],
page_title: page_title_translation + " :" + gadget.state.doc.title, page_title: page_title_translation + " :" + gadget.state.doc.title,
delete_url: url_list[2], delete_url: url_list[2],
transfer_url: url_list[3],
save_action: true save_action: true
}; };
if (gadget.state.doc.is_owner !== undefined) {
header_dict.transfer_url = url_list[3];
}
if (!gadget.state.editable) { if (!gadget.state.editable) {
header_dict.edit_content = url_list[0]; header_dict.edit_content = url_list[0];
} }
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.49948.50158.41267</string> </value> <value> <string>1009.17464.55631.39321</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1685554128.59</float> <float>1687465625.96</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -523,9 +523,11 @@ ...@@ -523,9 +523,11 @@
destroy_url: url_list[4], destroy_url: url_list[4],
rss_url: url_list[5], rss_url: url_list[5],
selection_url: url_list[6], selection_url: url_list[6],
transfer_url: url_list[7],
save_action: true save_action: true
}; };
if (gadget.state.doc.is_owner !== undefined) {
header_dict.transfer_url = url_list[7];
}
if (gadget.state.doc.slap_state === "start_requested") { if (gadget.state.doc.slap_state === "start_requested") {
header_dict.stop_url = url_list[3]; header_dict.stop_url = url_list[3];
} }
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.49946.40563.64597</string> </value> <value> <string>1008.51163.7897.31249</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1685554267.16</float> <float>1687459175.1</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
<string>my_monitor_scope</string> <string>my_monitor_scope</string>
<string>my_upgrade_scope</string> <string>my_upgrade_scope</string>
<string>my_source_section_title</string> <string>my_source_section_title</string>
<string>my_is_owner</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
<string>my_news</string> <string>my_news</string>
<string>my_source_project_title</string> <string>my_source_project_title</string>
<string>my_source_section_title</string> <string>my_source_section_title</string>
<string>my_is_owner</string>
</list> </list>
</value> </value>
</item> </item>
......
portal = context.getPortalObject()
user = portal.portal_membership.getAuthenticatedMember().getUserValue()
if user is None:
return
portal_type = context.getPortalType()
if portal_type in ["Compute Node", "Computer Network"]:
return user.getRelativeUrl() == context.getSourceAdministration()
if portal_type == "Instance Tree":
return user.getRelativeUrl() == context.getDestinationSection()
raise ValueError("Unsupported Type")
<?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>Document_isRequesterOrOwner</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
<string>my_source_title</string> <string>my_source_title</string>
<string>my_list_image</string> <string>my_list_image</string>
<string>my_fast_input_dict</string> <string>my_fast_input_dict</string>
<string>my_is_owner</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -314,6 +314,31 @@ ...@@ -314,6 +314,31 @@
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block> </tal:block>
<tal:block tal:define="menu_action python: 'Delete'">
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block tal:define="menu_action python: 'Transfer'">
<tr>
<td>waitForElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody></table> </tbody></table>
......
...@@ -309,7 +309,30 @@ ...@@ -309,7 +309,30 @@
dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-NETWORK-BY-PROJECT 0'}) "> dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-NETWORK-BY-PROJECT 0'}) ">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block> </tal:block>
<tal:block tal:define="menu_action python: 'Delete'">
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block tal:define="menu_action python: 'Transfer'">
<tr>
<td>waitForElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody></table> </tbody></table>
......
...@@ -317,6 +317,30 @@ ...@@ -317,6 +317,30 @@
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block> </tal:block>
<tal:block tal:define="menu_action python: 'RSS'">
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block tal:define="menu_action python: 'Transfer'">
<tr>
<td>waitForElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody></table> </tbody></table>
......
...@@ -275,6 +275,32 @@ ...@@ -275,6 +275,32 @@
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block> </tal:block>
<tal:block tal:define="menu_action python: 'RSS'">
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block tal:define="menu_action python: 'Transfer'">
<tr>
<td>waitForElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody></table> </tbody></table>
......
...@@ -480,6 +480,30 @@ ...@@ -480,6 +480,30 @@
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block> </tal:block>
<tal:block tal:define="menu_action python: 'Destroy'">
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block tal:define="menu_action python: 'Transfer'">
<tr>
<td>waitForElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody></table> </tbody></table>
......
...@@ -479,6 +479,30 @@ ...@@ -479,6 +479,30 @@
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block> </tal:block>
<tal:block tal:define="menu_action python: 'Destroy'">
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block tal:define="menu_action python: 'Transfer'">
<tr>
<td>waitForElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_header.html\')]//a[@data-i18n=\'%s\']' % menu_action"></td>
<td></td>
</tr>
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody> </tbody>
......
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