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
d5cc61e1
Commit
d5cc61e1
authored
Sep 01, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: move methods from State to PermissionRoles class
because they are related to the cells
parent
1e0b59d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
24 deletions
+23
-24
product/ERP5Workflow/Document/PermissionRoles.py
product/ERP5Workflow/Document/PermissionRoles.py
+21
-0
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+2
-24
No files found.
product/ERP5Workflow/Document/PermissionRoles.py
View file @
d5cc61e1
...
@@ -83,6 +83,27 @@ class PermissionRoles(XMLObject):
...
@@ -83,6 +83,27 @@ class PermissionRoles(XMLObject):
def
_getRoleIndex
(
self
):
def
_getRoleIndex
(
self
):
return
int
(
self
.
id
[
len
(
self
.
base_id
+
'_'
):].
split
(
'_'
)[
1
])
return
int
(
self
.
id
[
len
(
self
.
base_id
+
'_'
):].
split
(
'_'
)[
1
])
def
_getPermissionOrRole
(
self
,
is_role
=
False
):
# we want to get the permission or role from its index,
# so we want the retrieve the key of the dict which is like:
# self.index[cell_prefix][index] = {'Some Role Or Permission': 1,
# 'Some Other One': 0, ...}
if
is_role
:
cell_permission_or_role_index
=
self
.
_getRoleIndex
()
else
:
cell_permission_or_role_index
=
self
.
_getPermissionIndex
()
index
=
int
(
is_role
)
for
key
,
value
in
self
.
index
[
self
.
base_id
][
index
].
items
():
if
cell_permission_or_role_index
==
value
:
return
key
raise
ValueError
(
'No key found for value %s.'
%
value
)
def
_getPermission
(
self
):
return
self
.
_getPermissionOrRole
(
is_role
=
False
)
def
_getRole
(
self
):
return
self
.
_getPermissionOrRole
(
is_role
=
True
)
def
_setSelected
(
self
,
value
):
def
_setSelected
(
self
,
value
):
"""
"""
edit the parent state's permission/role dict to reflect current cell selection (selected) status
edit the parent state's permission/role dict to reflect current cell selection (selected) status
...
...
product/ERP5Workflow/Document/State.py
View file @
d5cc61e1
...
@@ -118,32 +118,10 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
...
@@ -118,32 +118,10 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
'current_inventory'
,
'current_inventory'
,
)
)
# move next 3 methods to PermissionRoles.py
def
_getCellPermissionOrRole
(
self
,
cell
,
is_role
):
# we want to get the permission or role from its index,
# so we want the retrieve the key of the dict which is like:
# self.index[cell_prefix][index] = {'Some Role Or Permission': 1,
# 'Some Other One': 0, ...}
if
is_role
:
cell_permission_or_role_index
=
cell
.
_getRoleIndex
()
else
:
cell_permission_or_role_index
=
cell
.
_getPermissionIndex
()
index
=
int
(
is_role
)
for
key
,
value
in
self
.
index
[
cell
.
base_id
][
index
].
items
():
if
cell_permission_or_role_index
==
value
:
return
key
raise
ValueError
(
'No key found for value %s.'
%
value
)
def
_getCellPermission
(
self
,
cell
):
return
self
.
_getCellPermissionOrRole
(
cell
,
False
)
def
_getCellRole
(
self
,
cell
):
return
self
.
_getCellPermissionOrRole
(
cell
,
True
)
def
updateCellFromCustomStorage
(
self
,
cell
,
**
kw
):
def
updateCellFromCustomStorage
(
self
,
cell
,
**
kw
):
"""
"""
Creates a new content as a matrix box cell.
Creates a new content as a matrix box cell.
"""
"""
cell_permission
=
self
.
_getCellPermission
(
cell
)
cell_permission
=
cell
.
_getPermission
(
)
cell_role
=
self
.
_getCellRole
(
cell
)
cell_role
=
cell
.
_getRole
(
)
cell
.
selected
=
cell_role
in
self
.
state_permission_roles
[
cell_permission
]
cell
.
selected
=
cell_role
in
self
.
state_permission_roles
[
cell_permission
]
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