From 4b6f91b3040ce10d9b9ebfc6ccd06d2ce8dce8d6 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Fri, 24 Dec 2021 09:50:25 +0100 Subject: [PATCH] delete-role --- scodoc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scodoc.py b/scodoc.py index 94c8a7f0..1be50552 100755 --- a/scodoc.py +++ b/scodoc.py @@ -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")