Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guillaume Hervier
slapos.core
Commits
25389a9c
Commit
25389a9c
authored
Jul 22, 2014
by
Alain Takoudjou
Committed by
Rafael Monnerat
Nov 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get the list of newest software release from software product
parent
e43b0395
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
264 additions
and
1 deletion
+264
-1
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/HostingSubscription_getNewerSofwareRelease.xml
...apos_cloud/HostingSubscription_getNewerSofwareRelease.xml
+80
-0
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareProduct_getSortedSoftwareReleaseList.xml
...os_cloud/SoftwareProduct_getSortedSoftwareReleaseList.xml
+103
-0
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSSoftwareProduct.py
...lapos_cloud/TestTemplateItem/testSlapOSSoftwareProduct.py
+80
-0
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/HostingSubscription_getNewerSofwareRelease.xml
0 → 100644
View file @
25389a9c
<?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>
_body
</string>
</key>
<value>
<string>
hosting_subscription = context\n
portal = context.getPortalObject()\n
\n
software_instance = hosting_subscription.getPredecessorValue()\n
software_release_list = context.SoftwareProduct_getSortedSoftwareReleaseList(\n
software_release_url=software_instance.getUrlString())\n
\n
if not software_release_list:\n
return ""\n
latest_software_release = software_release_list[0]\n
if software_release_list[0].getUrlString() == software_instance.getUrlString():\n
return ""\n
else:\n
return latest_software_release.getUrlString()\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
HostingSubscription_getNewerSofwareRelease
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareProduct_getSortedSoftwareReleaseList.xml
0 → 100644
View file @
25389a9c
<?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>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
portal = context.getPortalObject()\n
\n
if software_product_reference is None:\n
assert(software_release_url is not None)\n
software_product_reference = portal.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n
url_string=software_release_url\n
).getAggregateValue().getReference()\n
else:\n
# Don\'t accept both parameters\n
assert(software_release_url is None)\n
\n
product_list = portal.portal_catalog(\n
portal_type=\'Software Product\',\n
reference=software_product_reference,\n
validation_state=\'published\')\n
\n
if not product_list:\n
return []\n
if len(product_list) >
1:\n
raise NotImplementedError(\'Several Software Product with the same title.\')\n
\n
software_release_list = product_list[0].getAggregateRelatedValueList()\n
software_release_list = sorted(\n
software_release_list,\n
key=lambda software_release: software_release.getCreationDate(),\n
reverse=True,\n
)\n
\n
return [software_release for software_release in software_release_list\n
if software_release.getValidationState() in \n
["published"]\n
]\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
software_product_reference=None, software_release_url=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareProduct_getSortedSoftwareReleaseList
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSSoftwareProduct.py
0 → 100644
View file @
25389a9c
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
from
Products.SlapOS.tests.testSlapOSMixin
import
testSlapOSMixin
from
AccessControl
import
getSecurityManager
from
DateTime
import
DateTime
import
transaction
class
TestSoftwareReleaseListFromSoftwareProduct
(
testSlapOSMixin
):
def
afterSetUp
(
self
):
super
(
TestSoftwareReleaseListFromSoftwareProduct
,
self
).
afterSetUp
()
self
.
user_id
=
getSecurityManager
().
getUser
().
getId
()
def
beforeTearDown
(
self
):
transaction
.
abort
()
def
generateNewId
(
self
):
return
self
.
getPortalObject
().
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
def
test_getSortedSoftwareReleaseListFromSoftwareProduct
(
self
):
new_id
=
self
.
generateNewId
()
software_product
=
self
.
_makeSoftwareProduct
(
new_id
)
release_list
=
software_product
.
SoftwareProduct_getSortedSoftwareReleaseList
(
software_product
.
getReference
())
self
.
assertEqual
(
release_list
,
[])
# published software release
software_release1
=
self
.
_makeSoftwareRelease
(
new_id
)
software_release1
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/1.cfg'
)
software_release1
.
publish
()
software_release2
=
self
.
_makeSoftwareRelease
(
self
.
generateNewId
())
software_release2
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/2.cfg'
)
software_release2
.
publish
()
# 1 released software release, should not appear
software_release3
=
self
.
_makeSoftwareRelease
(
new_id
)
self
.
assertTrue
(
software_release3
.
getValidationState
()
==
'released'
)
software_release3
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/3.cfg'
)
self
.
tic
()
release_list
=
software_product
.
SoftwareProduct_getSortedSoftwareReleaseList
(
software_product
.
getReference
())
self
.
assertEquals
([
release
.
getUrlString
()
for
release
in
release_list
],
[
'http://example.org/2.cfg'
,
'http://example.org/1.cfg'
])
def
test_getSortedSoftwareReleaseListFromSoftwareProduct_Changed
(
self
):
new_id
=
self
.
generateNewId
()
software_product
=
self
.
_makeSoftwareProduct
(
new_id
)
release_list
=
software_product
.
SoftwareProduct_getSortedSoftwareReleaseList
(
software_product
.
getReference
())
self
.
assertEqual
(
release_list
,
[])
# 2 published software releases
software_release2
=
self
.
_makeSoftwareRelease
(
self
.
generateNewId
())
software_release2
.
publish
()
software_release2
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/2.cfg'
)
# Newest software release
software_release1
=
self
.
_makeSoftwareRelease
(
new_id
)
software_release1
.
publish
()
software_release1
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/1.cfg'
)
self
.
tic
()
release_list
=
software_product
.
SoftwareProduct_getSortedSoftwareReleaseList
(
software_product
.
getReference
())
self
.
assertEquals
([
release
.
getUrlString
()
for
release
in
release_list
],
[
'http://example.org/1.cfg'
,
'http://example.org/2.cfg'
])
master/bt5/slapos_cloud/bt/revision
View file @
25389a9c
308
\ No newline at end of file
309
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment