Commit f932e38f authored by Romain Courteaud's avatar Romain Courteaud

Fix the hypermedia API to fetch software installation on computer.

parent 9e96f6f1
...@@ -80,7 +80,7 @@ else:\n ...@@ -80,7 +80,7 @@ else:\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.computer" },\n "type": "application/vnd.slapos.org.hal+json; class=slapos.org.computer" },\n
\n \n
"http://slapos.org/reg/software": {\n "http://slapos.org/reg/software": {\n
"href": "%s/Computer_getHateoasSoftwareList" % context.absolute_url(),\n "href": "%s/Computer_getHateoasSoftwareInstallationList" % context.absolute_url(),\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.collection",\n "type": "application/vnd.slapos.org.hal+json; class=slapos.org.collection",\n
},\n },\n
\n \n
......
...@@ -80,12 +80,13 @@ else:\n ...@@ -80,12 +80,13 @@ else:\n
\n \n
for sql_obj in context.getPortalObject().portal_catalog(\n for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type=\'Software Installation\',\n portal_type=\'Software Installation\',\n
aggregate_relative_url=context.getRelativeUrl(),\n default_aggregate_uid=context.getUid(),\n
validation_state=\'validated\',\n
):\n ):\n
obj = sql_obj.getObject()\n obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'item\'].append({\n result_dict[\'_links\'][\'item\'].append({\n
\'href\': \'%s/Software_getHateoas\' % obj.absolute_url(),\n \'href\': \'%s/SoftwareInstallation_getHateoas\' % obj.absolute_url(),\n
\'type\': \'application/vnd.slapos.org.hal+json; class=slapos.org.software\',\n \'type\': \'application/vnd.slapos.org.hal+json; class=slapos.org.software_installation\',\n
})\n })\n
\n \n
response.setHeader(\'Content-Type\', type)\n response.setHeader(\'Content-Type\', type)\n
...@@ -98,7 +99,7 @@ else:\n ...@@ -98,7 +99,7 @@ else:\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Computer_getHateoasSoftwareList</string> </value> <value> <string>Computer_getHateoasSoftwareInstallationList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -80,7 +80,7 @@ else:\n ...@@ -80,7 +80,7 @@ else:\n
\n \n
for sql_obj in context.getPortalObject().portal_catalog(\n for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type="Computer",\n portal_type="Computer",\n
source_administration_uid=context.getUid(),\n default_source_administration_uid=context.getUid(),\n
):\n ):\n
obj = sql_obj.getObject()\n obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'item\'].append({\n result_dict[\'_links\'][\'item\'].append({\n
......
...@@ -56,7 +56,7 @@ if REQUEST is None:\n ...@@ -56,7 +56,7 @@ if REQUEST is None:\n
raise Unauthorized\n raise Unauthorized\n
\n \n
response = REQUEST.RESPONSE\n response = REQUEST.RESPONSE\n
type = \'application/vnd.slapos.org.hal+json; class=slapos.org.software\'\n type = \'application/vnd.slapos.org.hal+json; class=slapos.org.software_installation\'\n
\n \n
if REQUEST.other[\'method\'] != "GET":\n if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n response.setStatus(405)\n
...@@ -78,15 +78,17 @@ else:\n ...@@ -78,15 +78,17 @@ else:\n
\n \n
import json\n import json\n
result_dict = {\n result_dict = {\n
\'_class\': \'slapos.org.software\',\n \'_class\': \'slapos.org.software_installation\',\n
\'title\': context.getTitle(),\n \'title\': context.getTitle(),\n
\'software_url\': context.getUrlString(),\n
\'status\': state,\n \'status\': state,\n
\'_links\': {\n \'_links\': {\n
"self": { "href": context.Base_getRequestUrl(),\n "self": { "href": context.Base_getRequestUrl(),\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.software" },\n "type": "application/vnd.slapos.org.hal+json; class=slapos.org.software_installation" },\n
},\n },\n
}\n }\n
url_string = context.getUrlString(None)\n
if url_string is not None:\n
result_dict["_links"]["software_release"] = { "href": url_string }\n
\n \n
response.setHeader(\'Content-Type\', type)\n response.setHeader(\'Content-Type\', type)\n
return json.dumps(result_dict)\n return json.dumps(result_dict)\n
...@@ -98,7 +100,7 @@ else:\n ...@@ -98,7 +100,7 @@ else:\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Software_getHateoas</string> </value> <value> <string>SoftwareInstallation_getHateoas</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -322,7 +322,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin): ...@@ -322,7 +322,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
# Get user's software # Get user's software
##################################################### #####################################################
content_type = "application/vnd.slapos.org.hal+json; " \ content_type = "application/vnd.slapos.org.hal+json; " \
"class=slapos.org.software" "class=slapos.org.software_installation"
software_link_dict = software_collection_hal['_links']\ software_link_dict = software_collection_hal['_links']\
['item'][0] ['item'][0]
......
3 4
\ No newline at end of file \ No newline at end of file
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