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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
3bfdef98
Commit
3bfdef98
authored
Jun 07, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: fixup
parent
07d4861f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionChangeRequest_validateIfSubmitted.py
..._request/SubscriptionChangeRequest_validateIfSubmitted.py
+25
-14
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionChangeRequest_validateIfSubmitted.py
View file @
3bfdef98
...
...
@@ -5,6 +5,7 @@ if REQUEST is not None:
raise
Unauthorized
subscription_change_request
=
context
portal
=
context
.
getPortalObject
()
assert
subscription_change_request
.
getPortalType
()
==
'Subscription Change Request'
assert
subscription_change_request
.
getSimulationState
()
==
'submitted'
...
...
@@ -62,6 +63,30 @@ if subscription_change_request.getAggregateUid() != subscribed_item.getUid():
if
subscription_change_request
.
getDestination
()
==
open_sale_order
.
getDestination
():
return
invalidate
(
subscription_change_request
,
'Expected change on: destination'
)
# Change Subscripted Item user if needed
subscribed_item
=
open_order_movement
.
getAggregateValue
(
portal_type
=
[
'Instance Tree'
,
'Compute Node'
,
'Project'
])
if
subscribed_item
is
None
:
raise
NotImplementedError
(
'Unsupported subscribed item'
)
elif
subscribed_item
.
getPortalType
()
==
'Compute Node'
:
# No user is set on Compute Node
pass
elif
subscribed_item
.
getPortalType
()
==
'Instance Tree'
:
# Check if user does not already have a instance tree with the same title
# to prevent breaking slapos's request
existing_instance_tree
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Instance Tree'
,
title
=
{
'query'
:
subscribed_item
.
getTitle
(),
'key'
:
'ExactMatch'
},
destination_section__uid
=
subscription_change_request
.
getDestinationUid
()
)
if
existing_instance_tree
is
not
None
:
return
invalidate
(
subscription_change_request
,
'Instance Tree with the same title found: %s'
%
existing_instance_tree
.
getRelativeUrl
())
subscribed_item
.
edit
(
destination_section
=
subscription_change_request
.
getDestination
())
elif
subscribed_item
.
getPortalType
()
==
'Project'
:
subscribed_item
.
edit
(
destination
=
subscription_change_request
.
getDestination
())
else
:
raise
NotImplementedError
(
'Not implemented subscribed item'
)
# Create new Open Sale Order
next_open_sale_order
=
subscription_change_request
.
SubscriptionRequest_createOpenSaleOrder
()
current_date
=
getClosestDate
(
target_date
=
next_open_sale_order
.
getCreationDate
(),
precision
=
'day'
)
...
...
@@ -77,18 +102,4 @@ open_order_movement.OpenSaleOrderCell_createDiscountSalePackingList(
subscription_change_request
)
#, activate_kw=activate_kw)
# Change Subscripted Item user if needed
subscribed_item
=
open_order_movement
.
getAggregateValue
(
portal_type
=
[
'Instance Tree'
,
'Compute Node'
,
'Project'
])
if
subscribed_item
is
None
:
raise
NotImplementedError
(
'Unsupported subscribed item'
)
elif
subscribed_item
.
getPortalType
()
==
'Compute Node'
:
# No user is set on Compute Node
pass
elif
subscribed_item
.
getPortalType
()
==
'Instance Tree'
:
subscribed_item
.
edit
(
destination_section
=
subscription_change_request
.
getDestination
())
elif
subscribed_item
.
getPortalType
()
==
'Project'
:
subscribed_item
.
edit
(
destination
=
subscription_change_request
.
getDestination
())
else
:
raise
NotImplementedError
(
'Not implemented subscribed item'
)
return
invalidate
(
subscription_change_request
,
'New open order: %s'
%
next_open_sale_order
.
getRelativeUrl
())
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