Improved approach to permission check at runtime

This commit is contained in:
eeintech 2022-02-07 15:42:39 -05:00
parent fd63fcde43
commit 3b45c1406a

View File

@ -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