[roles] controller: Fixed setting permissions
This commit is contained in:
parent
064177542e
commit
03aa7a3231
|
@ -44,12 +44,11 @@ def update_role(role, new_name):
|
||||||
|
|
||||||
|
|
||||||
def set_permissions(role, permissions):
|
def set_permissions(role, permissions):
|
||||||
role.permissions.clear()
|
|
||||||
for name in permissions:
|
for name in permissions:
|
||||||
p = Permission.query.filter(Permission.name.in_(permissions)).all()
|
p = Permission.query.filter(Permission.name.in_(permissions)).all()
|
||||||
if not p or len(p) < len(permissions):
|
if not p or len(p) < len(permissions):
|
||||||
raise BadRequest("Invalid permission name >{}<".format(name))
|
raise BadRequest("Invalid permission name >{}<".format(name))
|
||||||
role.permissions.extend(p)
|
role.permissions = list(p)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue