mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improved approach to permission check at runtime
This commit is contained in:
parent
fd63fcde43
commit
3b45c1406a
@ -234,13 +234,13 @@ class RuleSet(models.Model):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# Check for children models which inherits from parent role
|
# Check for children models which inherits from parent role
|
||||||
for child in cls.RULESET_CHANGE_INHERIT:
|
for (parent, child) in cls.RULESET_CHANGE_INHERIT:
|
||||||
# Get child model name
|
# Get child model name
|
||||||
child_name = f'{child[0]}_{child[1]}'
|
parent_child_string = f'{parent}_{child}'
|
||||||
|
|
||||||
if child_name == table:
|
if parent_child_string == table:
|
||||||
# Check if parent role has change permission
|
# Check if parent role has change permission
|
||||||
if check_user_role(user, role, 'change'):
|
if check_user_role(user, parent, 'change'):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Print message instead of throwing an error
|
# Print message instead of throwing an error
|
||||||
|
Loading…
Reference in New Issue
Block a user