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
Eric Zheng
slapos.core
Commits
03c81da1
Commit
03c81da1
authored
Aug 27, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Implement request susbscription with token
parent
1e0bf417
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
176 additions
and
9 deletions
+176
-9
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Person_applyContractInvitation.py
...os_subscription_request/Person_applyContractInvitation.py
+2
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Person_applyContractInvitation.xml
...s_subscription_request/Person_applyContractInvitation.xml
+62
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
...est/SubscriptionRequestModule_requestSubscriptionProxy.py
+19
-8
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
..._request/SubscriptionRequest_requestPaymentTransaction.py
+2
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.xml
...request/SubscriptionRequest_requestPaymentTransaction.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_testSkippedReservationFree.py
...request/SubscriptionRequest_testSkippedReservationFree.py
+20
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_testSkippedReservationFree.xml
...equest/SubscriptionRequest_testSkippedReservationFree.xml
+70
-0
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Person_applyContractInvitation.py
0 → 100644
View file @
03c81da1
# To be rewrite on another business template
return
None
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Person_applyContractInvitation.xml
0 → 100644
View file @
03c81da1
<?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>
invitation_token=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Person_applyContractInvitation
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
View file @
03c81da1
...
@@ -47,8 +47,9 @@ if confirmation_required and not person_is_new:
...
@@ -47,8 +47,9 @@ if confirmation_required and not person_is_new:
if
target_language
is
None
:
if
target_language
is
None
:
target_language
=
portal
.
Localizer
.
get_selected_language
()
target_language
=
portal
.
Localizer
.
get_selected_language
()
contract
=
None
if
token
:
if
token
:
person
.
Person_applyContractInvitation
(
invitation_token
)
contract
=
person
.
Person_applyContractInvitation
(
invitation_token
)
subscription_request
=
context
.
subscription_request_module
.
newContent
(
subscription_request
=
context
.
subscription_request_module
.
newContent
(
portal_type
=
"Subscription Request"
,
portal_type
=
"Subscription Request"
,
...
@@ -59,29 +60,39 @@ subscription_request = context.subscription_request_module.newContent(
...
@@ -59,29 +60,39 @@ subscription_request = context.subscription_request_module.newContent(
subscription_request
.
setDefaultEmailText
(
email
)
subscription_request
.
setDefaultEmailText
(
email
)
def
wrapWithShadow
(
subscription_request
,
amount
,
subscription_reference
,
subscription_request_id
):
def
wrapWithShadow
(
subscription_request
,
amount
,
subscription_reference
,
subscription_request_id
,
contract
=
contract
):
subscription_request
.
activate
(
tag
=
"subscription_condition_%s"
%
subscription_request_id
subscription_request
.
activate
(
tag
=
"subscription_condition_%s"
%
subscription_request_id
).
SubscriptionRequest_applyCondition
(
subscription_reference
,
target_language
)
).
SubscriptionRequest_applyCondition
(
subscription_reference
,
target_language
)
return
subscription_request
.
SubscriptionRequest_requestPaymentTransaction
(
return
subscription_request
.
SubscriptionRequest_requestPaymentTransaction
(
amount
=
amount
,
amount
=
amount
,
tag
=
"subscription_%s"
%
subscription_request_id
,
tag
=
"subscription_%s"
%
subscription_request_id
,
target_language
=
target_language
target_language
=
target_language
,
contract
=
contract
)
)
payment
=
person
.
Person_restrictMethodAsShadowUser
(
payment
=
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
shadow_document
=
person
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
subscription_request
,
user_input_dict
[
"amount"
],
subscription_reference
,
subscription_request
.
getId
()])
argument_list
=
[
subscription_request
,
user_input_dict
[
"amount"
],
subscription_reference
,
subscription_request
.
getId
(),
contract
])
if
batch_mode
:
if
batch_mode
:
return
{
'subscription'
:
subscription_request
.
getRelativeUrl
(),
'payment'
:
payment
.
getRelativeUrl
()
}
return
{
'subscription'
:
subscription_request
.
getRelativeUrl
(),
'payment'
:
payment
.
getRelativeUrl
()
}
if
target_language
==
"zh"
:
# Wechat payment
if
target_language
==
"zh"
:
# Wechat payment
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
if
payment_transaction
.
PaymentTransaction_getTotalPayablePrice
()
>
0
:
return
payment_transaction
.
PaymentTransaction_redirectToManualWechatPayment
(
web_site
)
return
payment_transaction
.
PaymentTransaction_redirectToManualWechatPayment
(
web_site
)
return
payment_transaction
.
PaymentTransaction_redirectToManualFreePayment
(
web_site
)
else
:
# Payzen payment
else
:
# Payzen payment
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
if
payment_transaction
.
PaymentTransaction_getTotalPayablePrice
()
>
0
:
return
payment_transaction
.
PaymentTransaction_redirectToManualPayzenPayment
(
web_site
)
return
payment_transaction
.
PaymentTransaction_redirectToManualPayzenPayment
(
web_site
)
return
payment_transaction
.
PaymentTransaction_redirectToManualFreePayment
(
web_site
)
return
person
.
Person_restrictMethodAsShadowUser
(
return
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
shadow_document
=
person
,
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
View file @
03c81da1
...
@@ -23,6 +23,8 @@ if current_invoice is None:
...
@@ -23,6 +23,8 @@ if current_invoice is None:
stop_date
=
DateTime
()
stop_date
=
DateTime
()
)
)
if
context
.
SubscriptionRequest_testSkippedReservationFree
(
contract
):
amount
=
0
for
line
in
current_payment
.
contentValues
():
for
line
in
current_payment
.
contentValues
():
if
line
.
getSource
()
in
[
"account_module/bank"
,
"account_module/receivable"
]:
if
line
.
getSource
()
in
[
"account_module/bank"
,
"account_module/receivable"
]:
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.xml
View file @
03c81da1
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
amount, tag, target_language, REQUEST=None
</string>
</value>
<value>
<string>
amount, tag, target_language,
contract=None,
REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_testSkippedReservationFree.py
0 → 100644
View file @
03c81da1
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
# It is mandatory use pass a contract to skip reservation
# as annonymous can request via website knowning the user's
# email
if
contract
is
None
:
return
if
context
.
SubscriptionRequest_getTransactionalUser
()
is
not
None
:
if
contract
is
not
None
and
contract
.
getMaximumInvoiceDelay
()
>
0
:
return
True
else
:
person
=
context
.
getDestinationSectionValue
()
if
person
.
Entity_statSlapOSOutstandingAmount
()
>
0
:
return
if
contract
is
not
None
and
contract
.
getMaximumInvoiceDelay
()
>
0
:
return
True
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_testSkippedReservationFree.xml
0 → 100644
View file @
03c81da1
<?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>
contract=None, 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_testSkippedReservationFree
</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