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
91d60711
Commit
91d60711
authored
Sep 06, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Use activities everywhere that it is possible to defer heavy actions.
parent
018d5477
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
316 additions
and
89 deletions
+316
-89
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscritption.py
...request/SubscriptionRequestModule_requestSubscritption.py
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscritptionProxy.py
...st/SubscriptionRequestModule_requestSubscritptionProxy.py
+14
-58
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscritptionProxy.xml
...t/SubscriptionRequestModule_requestSubscritptionProxy.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_viewSubscriptionRequestList.xml
...SubscriptionRequestModule_viewSubscriptionRequestList.xml
+4
-4
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_applyCondition.py
...ubscription_request/SubscriptionRequest_applyCondition.py
+32
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_applyCondition.xml
...bscription_request/SubscriptionRequest_applyCondition.xml
+62
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.py
...ubscriptionRequest_createRelatedSaleInvoiceTransaction.py
+35
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.xml
...bscriptionRequest_createRelatedSaleInvoiceTransaction.xml
+70
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createUser.py
...os_subscription_request/SubscriptionRequest_createUser.py
+22
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createUser.xml
...s_subscription_request/SubscriptionRequest_createUser.xml
+71
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
..._request/SubscriptionRequest_requestPaymentTransaction.py
+4
-25
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscritption.py
View file @
91d60711
...
...
@@ -19,4 +19,4 @@ user_input_dict = {
"amount"
:
amount
}
return
context
.
SubscriptionRequestModule_requestSubscritptionProxy
(
default_email_text
,
user_input_dict
=
user_input_dict
,
batch_mode
=
0
)
default_email_text
,
subscription_reference
,
user_input_dict
=
user_input_dict
,
batch_mode
=
0
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscritptionProxy.py
View file @
91d60711
from
zExceptions
import
Unauthorized
from
DateTime
import
DateTime
import
json
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
# You always needs a user here
person
=
context
.
SubscriptionRequest_createUser
(
email
,
user_input_dict
[
'name'
])
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
person
is
None
:
# Create a Person document in order to generate the invoice.
person
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
default_email_text
=
email
,
first_name
=
user_input_dict
[
"name"
])
login
=
person
.
newContent
(
portal_type
=
"ERP5 Login"
,
reference
=
email
,
# Please generate a LAAARGE random password.
password
=
email
)
login
.
validate
()
person
.
validate
()
person
.
immediateReindexObject
()
login
.
immediateReindexObject
()
# Get Subscription condition for this Subscription Request
subscription_configuration
=
{
"instance_xml"
:
""
,
#context.getTextContent(),
"title"
:
"%s"
%
"Subscription for %s %s"
%
(
"vm"
,
email
),
#(context.getTitle(), email),
"software_type"
:
"cluster"
,
#context.getSourceReference(),
"url"
:
"http://ww.com/sss"
,
#context.getUrlString(),
"shared"
:
0
,
#context.getRootSlave(),
"subject_list"
:
[],
#context.getSubjectList(),
"sla_xml"
:
""
,
#context.getSlaXml()
}
software_title
=
subscription_configuration
[
"title"
]
subscription_request
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Subscription Request'
,
title
=
software_title
,
validation_state
=
(
'draft'
,
'submitted'
,)
)
# How to consider that an Subscription request is already there.
# Perhaps if a user return, he should be able to resume a subscription process.
if
subscription_request
is
not
None
:
return
json
.
dumps
(
"already-requested"
)
now
=
DateTime
()
subscription_request
=
context
.
subscription_request_module
.
newContent
(
source_reference
=
subscription_configuration
[
"software_type"
],
title
=
software_title
,
url_string
=
subscription_configuration
[
"url"
],
text_content
=
subscription_configuration
[
"instance_xml"
],
start_date
=
now
,
stop_date
=
now
+
30
,
root_slave
=
subscription_configuration
[
"shared"
],
subject_list
=
subscription_configuration
[
"subject_list"
],
portal_type
=
"Subscription Request"
,
destination_section_value
=
person
)
subscription_request
.
setDefaultEmailText
(
email
)
def
wrapWithShadow
(
subscription_request
,
amount
):
def
wrapWithShadow
(
subscription_request
,
amount
,
subscription_reference
):
subscription_request
.
activate
(
tag
=
"subscription_condition_%s"
%
subscription_request
.
getId
()
).
SubscriptionRequest_applyCondition
(
subscription_reference
)
return
subscription_request
.
SubscriptionRequest_requestPaymentTransaction
(
amount
=
amount
,
tag
=
"subscription_%s"
%
subscription_request
.
getId
())
payment
=
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
subscription_request
,
user_input_dict
[
"amount"
]])
argument_list
=
[
subscription_request
,
user_input_dict
[
"amount"
]
,
subscription_reference
])
if
batch_mode
:
return
{
'subscription'
:
subscription_request
.
getRelativeUrl
(),
'payment'
:
payment
.
getRelativeUrl
()
}
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
return
payment_transaction
.
PaymentTransaction_redirectToManualPayzenPayment
(
web_site
)
return
payment
.
PaymentTransaction_redirectToSubscriptionManualPayzenPayment
(
context
.
getWebSiteValue
())
return
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
callable_object
=
wrapRedirectWithShadow
,
argument_list
=
[
payment
,
context
.
getWebSiteValue
()])
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscritptionProxy.xml
View file @
91d60711
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
email, user_input_dict={}, batch_mode=True, REQUEST=None
</string>
</value>
<value>
<string>
email,
subscription_reference,
user_input_dict={}, batch_mode=True, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_viewSubscriptionRequestList.xml
View file @
91d60711
...
...
@@ -53,7 +53,9 @@
<item>
<key>
<string>
bottom
</string>
</key>
<value>
<list/>
<list>
<string>
listbox
</string>
</list>
</value>
</item>
<item>
...
...
@@ -71,9 +73,7 @@
<item>
<key>
<string>
left
</string>
</key>
<value>
<list>
<string>
listbox
</string>
</list>
<list/>
</value>
</item>
<item>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_applyCondition.py
0 → 100644
View file @
91d60711
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
subscription_condition
=
context
.
portal_catalog
(
portal_type
=
"Subscription Condition"
,
reference
=
subscription_reference
,
validation_state
=
"validated"
)
# Get Subscription condition for this Subscription Request
subscription_configuration
=
{
"instance_xml"
:
subscription_condition
.
getTextContent
(),
"software_type"
:
subscription_condition
.
getSourceReference
(),
"url"
:
subscription_condition
.
getUrlString
(),
"shared"
:
subscription_condition
.
getRootSlave
(),
"subject_list"
:
subscription_condition
.
getSubjectList
(),
"sla_xml"
:
subscription_condition
.
getSlaXml
(),
"specialise"
:
subscription_condition
.
getRelativeUrl
()
}
email
=
context
.
getDestinationSectionValue
().
getDefaultEmailText
()
now
=
DateTime
()
context
.
edit
(
source_reference
=
subscription_configuration
[
"software_type"
],
title
=
"Subscription %s for %s"
%
(
subscription_condition
.
getTitle
(),
email
),
url_string
=
subscription_configuration
[
"url"
],
text_content
=
subscription_configuration
[
"instance_xml"
],
start_date
=
now
,
root_slave
=
subscription_configuration
[
"shared"
],
subject_list
=
subscription_configuration
[
"subject_list"
],
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_applyCondition.xml
0 → 100644
View file @
91d60711
<?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>
subscription_reference, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SubscriptionRequest_applyCondition
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.py
0 → 100644
View file @
91d60711
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
current_invoice
=
context
.
getCausalityValue
()
if
current_invoice
is
None
:
invoice_template_path
=
"accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
invoice_template
=
portal
.
restrictedTraverse
(
invoice_template_path
)
current_invoice
=
invoice_template
.
Base_createCloneDocument
(
batch_mode
=
1
)
context
.
edit
(
causality_value
=
current_invoice
)
payment_transaction
=
invoice_template
=
portal
.
restrictedTraverse
(
payment
)
current_invoice
.
edit
(
title
=
"Reservation Fee"
,
source_value
=
context
.
getDestinationSection
(),
destination_value
=
context
.
getDestinationSection
(),
destination_section_value
=
context
.
getDestinationSection
(),
destination_decision_value
=
context
.
getDestinationSection
(),
start_date
=
payment_transaction
.
getStartDate
(),
stop_date
=
payment_transaction
.
getStopDate
(),
)
current_invoice
[
"1"
].
setQuantity
(
amount
)
comment
=
"Validation invoice for subscription request %s"
%
context
.
getRelativeUrl
()
current_invoice
.
plan
(
comment
=
comment
)
current_invoice
.
confirm
(
comment
=
comment
)
current_invoice
.
startBuilding
(
comment
=
comment
)
payment_transaction
.
setCausalityValue
(
current_invoice
)
current_invoice
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
return
current_invoice
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.xml
0 → 100644
View file @
91d60711
<?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>
amount, tag, payment, 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>
SubscriptionRequest_createRelatedSaleInvoiceTransaction
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createUser.py
0 → 100644
View file @
91d60711
portal
=
context
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
person
is
None
:
# Create a Person document in order to generate the invoice.
person
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
default_email_text
=
email
,
first_name
=
name
)
login
=
person
.
newContent
(
portal_type
=
"ERP5 Login"
,
reference
=
email
,
# Please generate a LAAARGE random password.
password
=
email
)
login
.
validate
()
person
.
validate
()
person
.
immediateReindexObject
()
login
.
immediateReindexObject
()
return
person
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createUser.xml
0 → 100644
View file @
91d60711
<?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>
email, name, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SubscriptionRequest_createUser
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
View file @
91d60711
...
...
@@ -7,28 +7,6 @@ portal = context.getPortalObject()
current_invoice
=
context
.
getCausalityValue
()
if
current_invoice
is
None
:
# Create the Pre-Payment Invoice invoice
# XXX Hardcoded
invoice_template
=
portal
.
restrictedTraverse
(
"accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
)
current_invoice
=
invoice_template
.
Base_createCloneDocument
(
batch_mode
=
1
)
context
.
edit
(
causality_value
=
current_invoice
)
current_invoice
.
edit
(
title
=
"Reservation Fee"
,
source_value
=
context
.
getDestinationSection
(),
destination_value
=
context
.
getDestinationSection
(),
destination_section_value
=
context
.
getDestinationSection
(),
destination_decision_value
=
context
.
getDestinationSection
(),
start_date
=
DateTime
(),
stop_date
=
DateTime
(),
)
current_invoice
[
"1"
].
setQuantity
(
amount
)
comment
=
"Validation invoice for subscription request %s"
%
context
.
getRelativeUrl
()
current_invoice
.
plan
(
comment
=
comment
)
current_invoice
.
confirm
(
comment
=
comment
)
current_invoice
.
startBuilding
(
comment
=
comment
)
current_invoice
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
payment_template
=
portal
.
restrictedTraverse
(
"accounting_module/slapos_pre_payment_template"
)
current_payment
=
payment_template
.
Base_createCloneDocument
(
batch_mode
=
1
)
...
...
@@ -39,9 +17,8 @@ if current_invoice is None:
destination_value
=
context
.
getDestinationSection
(),
destination_section_value
=
context
.
getDestinationSection
(),
destination_decision_value
=
context
.
getDestinationSection
(),
start_date
=
current_invoice
.
getStartDate
(),
stop_date
=
current_invoice
.
getStopDate
(),
causality_value
=
current_invoice
start_date
=
DateTime
(),
stop_date
=
DateTime
()
)
quantity
=
int
(
amount
)
*
19.95
for
line
in
current_payment
.
contentValues
():
...
...
@@ -59,5 +36,7 @@ if current_invoice is None:
context
.
immediateReindexObject
()
context
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
activate
(
tag
=
tag
).
SubscriptionRequest_createRelatedSaleInvoiceTransaction
(
amount
,
tag
,
current_payment
.
getRelativeUrl
())
return
current_payment
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