Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
d5591932
Commit
d5591932
authored
Feb 19, 2020
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_commerce: create user
parent
a519f8d4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
305 additions
and
46 deletions
+305
-46
bt5/erp5_commerce/ExtensionTemplateItem/portal_components/extension.erp5.Ecommerce.py
...emplateItem/portal_components/extension.erp5.Ecommerce.py
+20
-0
bt5/erp5_commerce/ExtensionTemplateItem/portal_components/extension.erp5.Ecommerce.xml
...mplateItem/portal_components/extension.erp5.Ecommerce.xml
+64
-46
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_createWebSiteAccount.py
...ortal_skins/erp5_commerce/WebSite_createWebSiteAccount.py
+90
-0
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_createWebSiteAccount.xml
...rtal_skins/erp5_commerce/WebSite_createWebSiteAccount.xml
+75
-0
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_executeMethodAsSuperUser.xml
..._skins/erp5_commerce/WebSite_executeMethodAsSuperUser.xml
+28
-0
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_immediateReindex.xml
...m/portal_skins/erp5_commerce/WebSite_immediateReindex.xml
+28
-0
No files found.
bt5/erp5_commerce/ExtensionTemplateItem/portal_components/extension.erp5.Ecommerce.py
View file @
d5591932
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
AccessControl.SecurityManagement
import
getSecurityManager
,
\
setSecurityManager
,
newSecurityManager
from
Products
import
ERP5Security
import
urllib
import
urllib
import
mechanize
import
mechanize
...
@@ -20,3 +25,18 @@ def submitPaypalNVPRequest(parameter_dict, nvp_url):
...
@@ -20,3 +25,18 @@ def submitPaypalNVPRequest(parameter_dict, nvp_url):
tmp
=
parameter
.
split
(
'='
)
tmp
=
parameter
.
split
(
'='
)
response_parameter_dict
[
tmp
[
0
]]
=
tmp
[
1
]
response_parameter_dict
[
tmp
[
0
]]
=
tmp
[
1
]
return
response_parameter_dict
return
response_parameter_dict
def
immediateReindex
(
self
):
self
.
immediateReindexObject
()
def
executeMethodAsSuperUser
(
self
,
method
,
**
kw
):
sm
=
getSecurityManager
()
try
:
#Use SUPER_USER
acl_users
=
self
.
getPortalObject
().
acl_users
newSecurityManager
(
None
,
acl_users
.
getUserById
(
ERP5Security
.
SUPER_USER
))
method
=
getattr
(
self
,
method
)
return
method
(
**
kw
)
finally
:
#Restore orinal user
setSecurityManager
(
sm
)
\ No newline at end of file
bt5/erp5_commerce/ExtensionTemplateItem/portal_components/extension.erp5.Ecommerce.xml
View file @
d5591932
...
@@ -6,10 +6,22 @@
...
@@ -6,10 +6,22 @@
</pickle>
</pickle>
<pickle>
<pickle>
<dictionary>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<item>
<key>
<string>
default_reference
</string>
</key>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
Ecommerce
</string>
</value>
<value>
<string>
Ecommerce
</string>
</value>
</item>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
extension.erp5.Ecommerce
</string>
</value>
<value>
<string>
extension.erp5.Ecommerce
</string>
</value>
...
@@ -24,6 +36,20 @@
...
@@ -24,6 +36,20 @@
<none/>
<none/>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 20, 2: No exception type(s) specified (bare-except)
</string>
</tuple>
</value>
</item>
<item>
<item>
<key>
<string>
version
</string>
</key>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
<value>
<string>
erp5
</string>
</value>
...
@@ -31,13 +57,28 @@
...
@@ -31,13 +57,28 @@
<item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<key>
<string>
workflow_history
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
</pickle>
...
@@ -50,7 +91,7 @@
...
@@ -50,7 +91,7 @@
<item>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
...
@@ -59,53 +100,30 @@
...
@@ -59,53 +100,30 @@
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
</pickle>
<pickle>
<pickle>
<tuple>
<dictionary>
<none/>
<item>
<list>
<key>
<string>
_log
</string>
</key>
<dictionary>
<value>
<item>
<list>
<key>
<string>
action
</string>
</key>
<dictionary>
<value>
<string>
validate
</string>
</value>
<item>
</item>
<key>
<string>
action
</string>
</key>
<item>
<value>
<string>
validate
</string>
</value>
<key>
<string>
actor
</string>
</key>
</item>
<value>
<string>
ERP5TypeTestCase
</string>
</value>
<item>
</item>
<key>
<string>
validation_state
</string>
</key>
<item>
<value>
<string>
validated
</string>
</value>
<key>
<string>
comment
</string>
</key>
</item>
<value>
<string></string>
</value>
</dictionary>
</item>
</list>
<item>
</value>
<key>
<string>
time
</string>
</key>
</item>
<value>
</dictionary>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1377844574.76
</float>
<string>
GMT+9
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</pickle>
</record>
</record>
</ZopeData>
</ZopeData>
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_createWebSiteAccount.py
0 → 100644
View file @
d5591932
from
Products.Formulator.Errors
import
ValidationError
,
FormValidationError
portal
=
context
.
getPortalObject
()
translateString
=
context
.
Base_translateString
website
=
context
.
getWebSiteValue
()
# Call Base_edit
result
,
result_type
=
context
.
Base_edit
(
form_id
,
silent_mode
=
1
,
field_prefix
=
'your_'
)
# Return if not appropriate
if
result_type
!=
'edit'
:
return
result
kw
,
encapsulated_editor_list
=
result
# Set default values
person_group
=
None
person_function
=
None
person_site
=
None
person_role
=
'client'
reference
=
kw
.
pop
(
'reference'
)
password
=
kw
.
pop
(
'password'
)
kw
.
pop
(
'password_confirm'
,
None
)
# Check that user doesn't already exists
person_list
=
[
x
for
x
in
portal
.
acl_users
.
searchUsers
(
login
=
reference
,
exact_match
=
True
)
if
'path'
in
x
]
if
person_list
:
msg
=
translateString
(
"This account already exists. Please provide another email address."
)
kw
[
'portal_status_message'
]
=
msg
context
.
REQUEST
.
form
.
update
(
kw
)
return
getattr
(
website
,
form_id
)()
# create Person account
person_module
=
portal
.
getDefaultModule
(
portal_type
=
'Person'
)
person
=
person_module
.
newContent
(
portal_type
=
'Person'
)
user_id
=
person
.
Person_getUserId
()
# Create default career
career
=
person
.
newContent
(
portal_type
=
'Career'
,
id
=
'default_career'
,
group
=
person_group
,
function
=
person_function
,
role
=
person_role
)
# Create assignment
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
group
=
person_group
,
function
=
person_function
,
role
=
person_role
,
# Required for security based on role
site
=
person_site
)
login
=
person
.
newContent
(
portal_type
=
'ERP5 Login'
,
reference
=
reference
,
password
=
password
)
login
.
validate
()
assignment
.
open
()
person
.
validate
()
person
.
updateLocalRolesOnSecurityGroups
()
person
.
WebSite_immediateReindex
()
login
.
WebSite_immediateReindex
()
person
.
WebSite_executeMethodAsSuperUser
(
'edit'
,
**
kw
)
is_shopping_cart
=
context
.
REQUEST
.
get
(
'is_shopping_cart'
)
if
is_shopping_cart
is
None
:
is_shopping_cart
=
context
.
REQUEST
.
get
(
'field_your_is_shopping_cart'
)
if
is_shopping_cart
:
msg
=
translateString
(
"Your account was successfully created, now you can proceed to payment."
)
else
:
msg
=
translateString
(
"Your account was successfully created."
)
# Set owner local role for cart if needed
shopping_cart
=
context
.
SaleOrder_getShoppingCart
()
if
shopping_cart
is
not
None
:
shopping_cart
.
manage_setLocalRoles
(
user_id
,
[
'Owner'
])
"""
response = context.REQUEST.RESPONSE
response.setHeader("__ac_name", reference)
response.setHeader("__ac_password", password)
"""
came_from
=
kw
[
'came_from'
]
if
came_from
:
from
ZTUtils
import
make_query
parameter_string
=
make_query
(
__ac_name
=
reference
,
__ac_password
=
password
,
portal_status_message
=
msg
,
editable_mode
=
0
)
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
'%s?%s'
%
(
came_from
,
parameter_string
))
return
website
.
Base_redirect
(
'/'
,
keep_items
=
dict
(
portal_status_message
=
msg
,
__ac_name
=
reference
,
# XXX - Make it generic
__ac_password
=
password
,
# XXX - Make it generic
editable_mode
=
0
))
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_createWebSiteAccount.xml
0 → 100644
View file @
d5591932
<?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>
form_id
</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>
WebSite_createWebSiteAccount
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Create Web Site User Account (MERGE THIS)
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_executeMethodAsSuperUser.xml
0 → 100644
View file @
d5591932
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
executeMethodAsSuperUser
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
Ecommerce
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebSite_executeMethodAsSuperUser
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_immediateReindex.xml
0 → 100644
View file @
d5591932
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
immediateReindex
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
Ecommerce
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebSite_immediateReindex
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></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