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
Cédric Le Ninivin
slapos.core
Commits
254a0599
Commit
254a0599
authored
Aug 18, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: Add script to apply Contract Invitation into Cloud Contract
parent
12185420
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
0 deletions
+135
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_base/Person_applyContractInvitation.py
...ortal_skins/slapos_base/Person_applyContractInvitation.py
+65
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_base/Person_applyContractInvitation.xml
...rtal_skins/slapos_base/Person_applyContractInvitation.xml
+70
-0
No files found.
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_base/Person_applyContractInvitation.py
0 → 100644
View file @
254a0599
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
if
cloud_invitation
is
None
:
return
None
portal
=
context
.
getPortalObject
()
contract_portal_type
=
"Cloud Contract"
tag
=
"%s_requestValidationPayment_inProgress"
%
context
.
getUid
()
if
(
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
):
# The cloud contract is already under creation but can not be fetched from catalog
# As it is not possible to fetch informations, it is better to raise an error
return
None
contract
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
contract_portal_type
,
default_destination_section_uid
=
context
.
getUid
(),
validation_state
=
[
'invalidated'
,
'validated'
],
)
if
(
contract
is
None
):
# Prevent concurrent transaction to create 2 contracts for the same context
context
.
serialize
()
# Time to create the contract
contract
=
portal
.
cloud_contract_module
.
newContent
(
portal_type
=
contract_portal_type
,
title
=
'Contract for "%s"'
%
context
.
getTitle
(),
destination_section_value
=
context
)
contract
.
validate
(
comment
=
'New automatic contract for %s (token: %s)'
%
(
context
.
getTitle
(),
cloud_invitation
.
getTitle
()))
contract
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
if
(
contract
.
getValidationState
()
==
"invalidated"
):
contract
.
validate
(
comment
=
'Validation by usaged of the token %s'
%
(
cloud_invitation
.
getTitle
()))
contract
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
# Cloud invitation maximizes contract, so we keep the maximum value between the 2, we never
# decrease.
if
cloud_invitation
.
getMaximumInvoiceDelay
(
0
)
>
contract
.
getMaximumInvoiceDelay
(
0
):
contract
.
edit
(
maximum_invoice_delay
=
cloud_invitation
.
getMaximumInvoiceDelay
())
# Hardcoded Values
for
invitation_line
in
cloud_invitation
.
objectValues
():
has_line
=
False
for
line
in
contract
.
objectValues
():
if
line
.
getPriceCurrency
()
==
invitation_line
.
getPriceCurrency
()
and
\
invitation_line
.
getMaximumInvoiceCredit
(
0
)
>
line
.
getMaximumInvoiceCredit
(
0
):
line
.
edit
(
maximum_invoice_credit
=
invitation_line
.
getMaximumInvoiceCredit
())
has_line
=
True
break
if
not
has_line
:
contract
.
newContent
(
portal_type
=
"Cloud Contract Line"
,
maximum_invoice_credit
=
invitation_line
.
getMaximumInvoiceCredit
(),
price_currency
=
invitation_line
.
getPriceCurrency
()
)
cloud_invitation
.
invalidate
()
return
contract
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_base/Person_applyContractInvitation.xml
0 → 100644
View file @
254a0599
<?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>
_params
</string>
</key>
<value>
<string>
cloud_invitation, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Person_applyContractInvitation
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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