added set admin function
This commit is contained in:
@@ -37,6 +37,7 @@ class API_Handler:
|
||||
set_portfolio(user_id, portfolio): sets the portfolio of the user
|
||||
delete_portfolio(user_id, portfolio): deletes the portfolio of the user
|
||||
set_cron_interval(user_id, interval): sets the cron interval of the user
|
||||
set_admin(email, is_admin): sets the admin status of the user with the given email
|
||||
"""
|
||||
|
||||
|
||||
@@ -334,6 +335,22 @@ class API_Handler:
|
||||
return req.status_code
|
||||
|
||||
|
||||
def set_admin(self, email, is_admin):
|
||||
"""sets the admin of the user
|
||||
|
||||
Args:
|
||||
email (string): email of the user
|
||||
is_admin (String): "true" if user should be Admin, "false" if not
|
||||
|
||||
Returns:
|
||||
int: status code
|
||||
"""
|
||||
with r.Session() as s:
|
||||
headers = {'Authorization': 'Bearer ' + self.token} # only bot token is needed, user is chosen by email
|
||||
req = s.put(self.db_adress + "/user/setAdmin", json={"admin": str(is_admin),"email": str(email)})
|
||||
return req.status_code
|
||||
|
||||
|
||||
if __name__ == "__main__": # editable, just for basic on the go testing of new functions
|
||||
|
||||
print("This is a module for the telegram bot. It is not intended to be run directly.")
|
||||
@@ -346,6 +363,8 @@ if __name__ == "__main__": # editable, just for basic on the go testing of new f
|
||||
user = handler.get_user(user_id = 1709356058)
|
||||
print(user)
|
||||
all_users = handler.get_all_users()
|
||||
admin_status = handler.set_admin("test@test.com", "true")
|
||||
print(admin_status)
|
||||
print(all_users)
|
||||
print(shares)
|
||||
sys.exit(1)
|
Reference in New Issue
Block a user