delete-role

This commit is contained in:
Arthur ZHU 2021-12-24 09:50:25 +01:00
parent d740244d25
commit 4b6f91b304

View File

@ -248,6 +248,16 @@ def edit_role(rolename, addpermissionname=None, removepermissionname=None): # e
db.session.add(role)
db.session.commit()
@app.cli.command()
@click.argument("rolename")
def delete_role(rolename):
"""Delete a role"""
role = Role.query.filter_by(name=rolename).first()
if role is None:
sys.stderr.write(f"delete_role: role {rolename} does not exists\n")
return 1
db.session.delete(role)
db.session.commit()
@app.cli.command()
@click.argument("username")