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
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
alecs_myu
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
Hide 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,12 +4755,15 @@ class LocalRolesTemplateItem(BaseTemplateItem):
xml_data
=
'<local_roles_item>'
# local roles
xml_data
+=
'
\
n
<local_roles>'
for
key
in
sorted
(
local_roles_dict
):
xml_data
+=
"
\
n
<role id='%s'>"
%
(
key
,)
tuple
=
local_roles_dict
[
key
]
for
item
in
tuple
:
xml_data
+=
"
\
n
<item>%s</item>"
%
(
item
,)
xml_data
+=
'
\
n
</role>'
for
user_id
,
role_list
in
sorted
(
local_roles_dict
.
items
()):
if
'Owner'
in
role_list
:
# We don't export Owner role as it set automatically when installing business template.
role_list
.
remove
(
'Owner'
)
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
</local_roles>'
if
local_roles_group_id_dict
:
...
...
@@ -4829,6 +4832,18 @@ class LocalRolesTemplateItem(BaseTemplateItem):
else
:
local_roles_group_id_dict
=
None
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
if
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
import
logging
from
unittest
import
expectedFailure
,
skip
from
AccessControl
import
getSecurityManager
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Acquisition
import
aq_base
from
OFS.SimpleItem
import
SimpleItem
...
...
@@ -2329,15 +2330,25 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
"""
Create local roles
"""
new_local_roles
=
{
'ac'
:[
'Owner'
,
'Manager'
],
'group_function'
:
[
'Auditor'
]}
# We'll export an owner in local roles ...
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
()
module_id
=
sequence
.
get
(
'module_id'
)
module
=
p
.
_getOb
(
module_id
,
None
)
self
.
assertTrue
(
module
is
not
None
)
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
):
"""
...
...
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