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
Sebastien Robin
erp5
Commits
1755c61b
Commit
1755c61b
authored
Aug 31, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: override edit on PermissionRoles cells to save changes in the state
data structure state_permission_roles
parent
ced674e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
product/ERP5Workflow/Document/PermissionRoles.py
product/ERP5Workflow/Document/PermissionRoles.py
+37
-1
No files found.
product/ERP5Workflow/Document/PermissionRoles.py
View file @
1755c61b
...
...
@@ -43,7 +43,7 @@ class PermissionRoles(XMLObject):
portal_type
=
'PermissionRoles'
add_permission
=
Permissions
.
AddPortalContent
isIndexable
=
ConstantGetter
(
'isIndexable'
,
value
=
False
)
is_selected
=
0
#
for checkerbox (True 1 /False 0)
is_selected
=
0
#
checkerbox
isPortalContent
=
1
isRADContent
=
1
...
...
@@ -76,3 +76,39 @@ class PermissionRoles(XMLObject):
if
role
==
'None'
:
role
=
[
'Manager'
]
return
permission
,
role
def
getCellInfo
(
self
):
(
cell_permission_index
,
cell_role_index
)
=
self
.
id
[
len
(
self
.
base_id
+
'_'
):]
\
.
split
(
'_'
)
return
{
'prefix'
:
self
.
base_id
,
'permission_index'
:
int
(
cell_permission_index
),
'role_index'
:
int
(
cell_role_index
)}
def
editStatePermissionRolesFromCellSelection
(
self
,
value
):
"""
edit the parent state's permission/role dict to reflect current cell selection (is_selected) status
"""
state
=
self
.
getParentValue
()
cell_info
=
self
.
getCellInfo
()
cell_range
=
state
.
getCellRange
()
cell_permission
=
sorted
(
cell_range
[
0
])[
cell_info
[
'permission_index'
]]
cell_role
=
sorted
(
cell_range
[
1
])[
cell_info
[
'role_index'
]]
# update the state permission structure to take into account
# the selection/non-selection of this cell
if
value
and
(
cell_role
not
in
state
.
state_permission_roles
[
cell_permission
]):
roles
=
state
.
state_permission_roles
[
cell_permission
]
acquired
=
isinstance
(
roles
,
tuple
)
roles
=
list
(
set
(
roles
))
roles
.
append
(
cell_role
)
state
.
setPermission
(
cell_permission
,
acquired
,
roles
)
# XXX(WORKFLOW) set acquire value correctly
if
(
not
value
)
and
(
cell_role
in
state
.
state_permission_roles
[
cell_permission
]):
roles
=
state
.
state_permission_roles
[
cell_permission
]
acquired
=
isinstance
(
roles
,
tuple
)
roles
=
list
(
set
(
roles
))
roles
.
remove
(
cell_role
)
state
.
setPermission
(
cell_permission
,
acquired
,
roles
)
def
edit
(
self
,
*
args
,
**
kw
):
super
(
PermissionRoles
,
self
).
edit
(
*
args
,
**
kw
)
if
kw
.
get
(
'is_selected'
)
is
not
None
:
self
.
editStatePermissionRolesFromCellSelection
(
kw
[
'is_selected'
])
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