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
Xiaowu Zhang
slapos.core
Commits
e438bfa1
Commit
e438bfa1
authored
Oct 08, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: Add action to generate a cloud contract for a Person
parent
af58cb49
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
202 additions
and
47 deletions
+202
-47
master/bt5/slapos_accounting/ActionTemplateItem/portal_types/Person/create_new_cloud_contract.xml
...ateItem/portal_types/Person/create_new_cloud_contract.xml
+81
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Person_generateCloudContract.py
...tal_skins/slapos_contract/Person_generateCloudContract.py
+57
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Person_generateCloudContract.xml
...al_skins/slapos_contract/Person_generateCloudContract.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/SoftwareInstance_requestValidationPayment.py
...pos_contract/SoftwareInstance_requestValidationPayment.py
+1
-47
master/bt5/slapos_accounting/bt/template_action_path_list
master/bt5/slapos_accounting/bt/template_action_path_list
+1
-0
No files found.
master/bt5/slapos_accounting/ActionTemplateItem/portal_types/Person/create_new_cloud_contract.xml
0 → 100644
View file @
e438bfa1
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ActionInformation"
module=
"Products.CMFCore.ActionInformation"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_jio_action
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_jio_action
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
create_new_cloud_contract
</string>
</value>
</item>
<item>
<key>
<string>
permissions
</string>
</key>
<value>
<tuple>
<string>
View
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
priority
</string>
</key>
<value>
<float>
50.0
</float>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Create Cloud Contract
</string>
</value>
</item>
<item>
<key>
<string>
visible
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Expression"
module=
"Products.CMFCore.Expression"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
text
</string>
</key>
<value>
<string>
string:${object_url}/Person_generateCloudContract
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Person_generateCloudContract.py
0 → 100644
View file @
e438bfa1
portal
=
context
.
getPortalObject
()
if
context
.
getPortalType
()
!=
"Person"
:
raise
ValueError
(
"This script can only be called under person context"
)
payment_portal_type
=
"Payment Transaction"
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'
],
)
msg
=
context
.
Base_translateString
(
"Cloud Contract related to %s"
%
context
.
getTitle
())
if
(
contract
is
None
):
# Prevent concurrent transaction to create 2 contracts for the same person
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'
%
context
.
getTitle
())
contract
.
invalidate
(
comment
=
'New automatic contract for %s'
%
context
.
getTitle
())
contract
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
msg
=
context
.
Base_translateString
(
"Cloud Contract created."
)
if
(
contract
.
getValidationState
()
==
"invalidated"
):
# search if the user already paid anything
payment
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
payment_portal_type
,
default_destination_section_uid
=
context
.
getUid
(),
simulation_state
=
[
'stopped'
],
)
if
(
payment
is
not
None
):
# Found one payment, the contract can be validated
comment
=
"Contract validated as paid payment %s found"
%
payment
.
getRelativeUrl
()
contract
.
validate
(
comment
=
comment
)
contract
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
if
batch
:
return
contract
return
contract
.
Base_redirect
(
keep_items
=
{
"portal_status_message"
:
msg
})
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/Person_generateCloudContract.xml
0 → 100644
View file @
e438bfa1
<?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>
batch=False
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Person_generateCloudContract
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_contract/SoftwareInstance_requestValidationPayment.py
View file @
e438bfa1
...
...
@@ -2,7 +2,6 @@ from zExceptions import Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
software_instance
=
context
hosting_subscription
=
software_instance
.
getSpecialiseValue
()
if
hosting_subscription
is
None
:
...
...
@@ -11,49 +10,4 @@ person = hosting_subscription.getDestinationSectionValue(portal_type='Person')
if
person
is
None
:
return
payment_portal_type
=
"Payment Transaction"
contract_portal_type
=
"Cloud Contract"
tag
=
"%s_requestValidationPayment_inProgress"
%
person
.
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
=
person
.
getUid
(),
validation_state
=
[
'invalidated'
,
'validated'
],
)
if
(
contract
is
None
):
# Prevent concurrent transaction to create 2 contracts for the same person
person
.
serialize
()
# Time to create the contract
contract
=
portal
.
cloud_contract_module
.
newContent
(
portal_type
=
contract_portal_type
,
title
=
'Contract for "%s"'
%
person
.
getTitle
(),
destination_section_value
=
person
)
contract
.
validate
(
comment
=
'New automatic contract for %s'
%
context
.
getTitle
())
contract
.
invalidate
(
comment
=
'New automatic contract for %s'
%
context
.
getTitle
())
contract
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
if
(
contract
.
getValidationState
()
==
"invalidated"
):
# search if the user already paid anything
payment
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
payment_portal_type
,
default_destination_section_uid
=
person
.
getUid
(),
simulation_state
=
[
'stopped'
],
)
if
(
payment
is
not
None
):
# Found one payment, the contract can be validated
comment
=
"Contract validated as paid payment %s found"
%
payment
.
getRelativeUrl
()
contract
.
validate
(
comment
=
comment
)
contract
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
return
contract
return
person
.
Person_generateCloudContract
(
batch
=
True
)
master/bt5/slapos_accounting/bt/template_action_path_list
View file @
e438bfa1
...
...
@@ -8,6 +8,7 @@ Consumption Document Module | view
Hosting Subscription | jump_to_related_open_order_line
Hosting Subscription | periodicity
Payment Transaction | related_payzen_event
Person | create_new_cloud_contract
Person | jump_to_cloud_contract
Root Applied Rule Causality Causality Movement Group | view
Sale Invoice Transaction | create_slapos_reversal
...
...
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