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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Lu Xu
erp5
Commits
8217bffe
Commit
8217bffe
authored
Oct 26, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
business template: do not export owner role in LocalRoleTemplateItem
parent
a84d5aed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+21
-6
product/ERP5/tests/testBusinessTemplate.py
product/ERP5/tests/testBusinessTemplate.py
+14
-3
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
8217bffe
...
@@ -4755,11 +4755,14 @@ class LocalRolesTemplateItem(BaseTemplateItem):
...
@@ -4755,11 +4755,14 @@ class LocalRolesTemplateItem(BaseTemplateItem):
xml_data
=
'<local_roles_item>'
xml_data
=
'<local_roles_item>'
# local roles
# local roles
xml_data
+=
'
\
n
<local_roles>'
xml_data
+=
'
\
n
<local_roles>'
for
key
in
sorted
(
local_roles_dict
):
for
user_id
,
role_list
in
sorted
(
local_roles_dict
.
items
()):
xml_data
+=
"
\
n
<role id='%s'>"
%
(
key
,)
if
'Owner'
in
role_list
:
tuple
=
local_roles_dict
[
key
]
# We don't export Owner role as it set automatically when installing business template.
for
item
in
tuple
:
role_list
.
remove
(
'Owner'
)
xml_data
+=
"
\
n
<item>%s</item>"
%
(
item
,)
if
role_list
:
xml_data
+=
"
\
n
<role id='%s'>"
%
(
user_id
,)
for
role
in
role_list
:
xml_data
+=
"
\
n
<item>%s</item>"
%
(
role
,)
xml_data
+=
'
\
n
</role>'
xml_data
+=
'
\
n
</role>'
xml_data
+=
'
\
n
</local_roles>'
xml_data
+=
'
\
n
</local_roles>'
...
@@ -4829,6 +4832,18 @@ class LocalRolesTemplateItem(BaseTemplateItem):
...
@@ -4829,6 +4832,18 @@ class LocalRolesTemplateItem(BaseTemplateItem):
else
:
else
:
local_roles_group_id_dict
=
None
local_roles_group_id_dict
=
None
local_roles_dict
,
=
self
.
_objects
[
roles_path
]
local_roles_dict
,
=
self
.
_objects
[
roles_path
]
# We ignore the owner defined in local_roles_dict and set it to the user installing that business template.
local_roles_dict
=
deepcopy
(
local_roles_dict
)
for
user_id
,
group_list
in
list
(
local_roles_dict
.
items
()):
if
group_list
==
[
"Owner"
]:
del
local_roles_dict
[
user_id
]
current_user
=
getSecurityManager
().
getUser
()
if
current_user
is
not
None
:
current_user_id
=
current_user
.
getId
()
if
current_user_id
is
not
None
:
local_roles_dict
.
setdefault
(
current_user_id
,
[]).
append
(
'Owner'
)
obj
.
__ac_local_roles__
=
local_roles_dict
obj
.
__ac_local_roles__
=
local_roles_dict
if
local_roles_group_id_dict
:
if
local_roles_group_id_dict
:
obj
.
__ac_local_roles_group_id_dict__
=
local_roles_group_id_dict
obj
.
__ac_local_roles_group_id_dict__
=
local_roles_group_id_dict
...
...
product/ERP5/tests/testBusinessTemplate.py
View file @
8217bffe
...
@@ -31,6 +31,7 @@ import unittest
...
@@ -31,6 +31,7 @@ import unittest
import
logging
import
logging
from
unittest
import
expectedFailure
,
skip
from
unittest
import
expectedFailure
,
skip
from
AccessControl
import
getSecurityManager
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
...
@@ -2329,15 +2330,25 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
...
@@ -2329,15 +2330,25 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
"""
"""
Create local roles
Create local roles
"""
"""
new_local_roles
=
{
'ac'
:[
'Owner'
,
'Manager'
],
# We'll export an owner in local roles ...
'group_function'
:
[
'Auditor'
]}
new_local_roles
=
{
'ac'
:
[
'Owner'
,
'Manager'
],
'group_function'
:
[
'Auditor'
]
}
# ... but after installing this business template, the owner
# will be reset:
expected_local_roles
=
{
'ac'
:
[
'Manager'
],
getSecurityManager
().
getUser
().
getId
():
[
'Owner'
],
'group_function'
:
[
'Auditor'
]
}
p
=
self
.
getPortal
()
p
=
self
.
getPortal
()
module_id
=
sequence
.
get
(
'module_id'
)
module_id
=
sequence
.
get
(
'module_id'
)
module
=
p
.
_getOb
(
module_id
,
None
)
module
=
p
.
_getOb
(
module_id
,
None
)
self
.
assertTrue
(
module
is
not
None
)
self
.
assertTrue
(
module
is
not
None
)
module
.
__ac_local_roles__
=
new_local_roles
module
.
__ac_local_roles__
=
new_local_roles
self
.
assertEqual
(
module
.
__ac_local_roles__
,
new_local_roles
)
self
.
assertEqual
(
module
.
__ac_local_roles__
,
new_local_roles
)
sequence
.
edit
(
local_roles
=
new
_local_roles
)
sequence
.
edit
(
local_roles
=
expected
_local_roles
)
def
stepRemoveLocalRoles
(
self
,
sequence
=
None
,
**
kw
):
def
stepRemoveLocalRoles
(
self
,
sequence
=
None
,
**
kw
):
"""
"""
...
...
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