Skip to content

Commit

Permalink
add command to make user a platform admin (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored Jul 22, 2024
1 parent 767bb04 commit 32737c5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,3 +1045,20 @@ def fix_billable_units():
Notification.query.filter(Notification.id == notification.id).update({"billable_units": template.fragment_count})
db.session.commit()
print("End fix_billable_units")


@notify_command(name="admin")
@click.option("-u", "--user_email", required=True, help="user email address")
@click.option("--on/--off", required=False, default=True, show_default="on", help="set admin on or off")
def toggle_admin(user_email, on):
"""
Set a user to be a platform admin or not
"""
try:
user = User.query.filter(User.email_address == user_email).one()
except NoResultFound:
print(f"User {user_email} not found")
return
user.platform_admin = on
db.session.commit()
print(f"User {user.email_address} is now {'an admin' if user.platform_admin else 'not an admin'}")

0 comments on commit 32737c5

Please sign in to comment.