add grant_permission() function
This commit is contained in:
parent
fb3c5c5ade
commit
dc037faabe
1 changed files with 12 additions and 0 deletions
|
@ -93,6 +93,18 @@ def guest_role(session):
|
||||||
return admin
|
return admin
|
||||||
|
|
||||||
|
|
||||||
|
def grant_permission(role, permission, session=None):
|
||||||
|
"""
|
||||||
|
Grants ``permission`` to ``role``.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not session:
|
||||||
|
session = object_session(role)
|
||||||
|
assert session
|
||||||
|
if permission not in role.permissions:
|
||||||
|
role.permissions.append(permission)
|
||||||
|
|
||||||
|
|
||||||
def has_permission(obj, perm, session=None):
|
def has_permission(obj, perm, session=None):
|
||||||
"""
|
"""
|
||||||
Checks the given ``obj`` (which may be either a :class:`edbob.User`` or
|
Checks the given ``obj`` (which may be either a :class:`edbob.User`` or
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue