mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
notify-api-533 add flask command to promote user to platform admin
This commit is contained in:
@@ -830,3 +830,18 @@ def create_new_service(name, message_limit, restricted, email_from, created_by_i
|
||||
except IntegrityError:
|
||||
print("duplicate service", service.name)
|
||||
db.session.rollback()
|
||||
|
||||
|
||||
@notify_command(name="promote-user-to-platform-admin")
|
||||
@click.option("-u", "--user-email-address", required=True, prompt=True)
|
||||
def promote_user_to_platform_admin(user_email_address):
|
||||
print("enter")
|
||||
user = get_user_by_email(user_email_address)
|
||||
print(f"user is {user}")
|
||||
# if not user:
|
||||
# raise ValueError(f"could not find user for {user_email_address}")
|
||||
print("ok to proceed")
|
||||
user.platform_admin = True
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
print("finished")
|
||||
|
||||
@@ -17,13 +17,6 @@ class DAOClass(object):
|
||||
if _commit:
|
||||
db.session.commit()
|
||||
|
||||
def update_instance(self, inst, update_dict, _commit=True):
|
||||
# Make sure the id is not included in the update_dict
|
||||
update_dict.pop("id")
|
||||
self.Meta.model.query.filter_by(id=inst.id).update(update_dict)
|
||||
if _commit:
|
||||
db.session.commit()
|
||||
|
||||
def delete_instance(self, inst, _commit=True):
|
||||
db.session.delete(inst)
|
||||
if _commit:
|
||||
|
||||
Reference in New Issue
Block a user