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
fd41318b
Commit
fd41318b
authored
May 27, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: detect unexpected changes
parent
b1725375
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionChangeRequest_validateIfSubmitted.py
..._request/SubscriptionChangeRequest_validateIfSubmitted.py
+44
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionChangeRequest_validateIfSubmitted.xml
...request/SubscriptionChangeRequest_validateIfSubmitted.xml
+1
-1
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionChangeRequest_validateIfSubmitted.py
View file @
fd41318b
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
subscription_change_request
=
context
assert
subscription_change_request
.
getPortalType
()
==
'Subscription Change Request'
assert
subscription_change_request
.
getSimulationState
()
==
'submitted'
def
invalidate
(
document
,
comment
):
context
.
validate
()
...
...
@@ -9,4 +15,41 @@ open_sale_order = subscription_change_request.getCausalityValue(portal_type='Ope
if
(
open_sale_order
is
None
)
or
(
open_sale_order
.
getValidationState
()
!=
'validated'
):
return
invalidate
(
subscription_change_request
,
'No Open Sale Order to update'
)
return
invalidate
(
subscription_change_request
,
'Unknowned requested changes'
)
# Search the line/cell
open_order_movement
=
None
open_order_movement_list
=
open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
)
if
len
(
open_order_movement_list
)
==
1
:
open_order_movement
=
open_order_movement_list
[
0
]
open_order_movement_list
=
open_order_movement
.
contentValues
(
portal_type
=
'Open Sale Order Cell'
)
if
1
<
len
(
open_order_movement_list
):
open_order_movement
=
None
elif
1
==
len
(
open_order_movement_list
):
open_order_movement
=
open_order_movement_list
[
0
]
if
open_order_movement
is
None
:
return
invalidate
(
subscription_change_request
,
'Can not find the open order movement'
)
identical_order_base_category_list
=
[
'specialise'
,
'destination'
,
'destination_section'
,
'destination_decisition'
,
'destination_project'
,
'source'
,
'source_section'
,
'source_project'
,
'price_currency'
,
'resource'
,
'variation_category_list'
,
'quantity_unit'
,
'aggregate'
,
'quantity'
,
'price'
]
for
identical_order_base_category
in
identical_order_base_category_list
:
if
open_order_movement
.
getProperty
(
identical_order_base_category
)
!=
subscription_change_request
.
getProperty
(
identical_order_base_category
):
return
invalidate
(
subscription_change_request
,
'Unhandled requested changes on: %s'
%
identical_order_base_category
)
return
invalidate
(
subscription_change_request
,
'Unknown requested changes'
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionChangeRequest_validateIfSubmitted.xml
View file @
fd41318b
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
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