Refactor managed roles to users controller/model

This commit is contained in:
Andrew 2022-08-20 12:56:38 -04:00
parent 31b75b1c50
commit 245d64ca45
4 changed files with 14 additions and 8 deletions

View File

@ -67,10 +67,6 @@ class RolesController:
def add_role(role_name, manager):
return HelperRoles.add_role(role_name, manager)
@staticmethod
def get_managed_roles(exec_user_id):
return HelperRoles.get_managed_roles(exec_user_id)
class RoleServerJsonType(t.TypedDict):
server_id: t.Union[str, int]
permissions: str

View File

@ -1,5 +1,6 @@
import logging
import typing as t
from app.classes.models.servers import HelperServers
from app.classes.models.users import HelperUsers
from app.classes.models.roles import HelperRoles
@ -137,6 +138,14 @@ class UsersController:
def get_managed_users(exec_user_id):
return HelperUsers.get_managed_users(exec_user_id)
@staticmethod
def get_managed_roles(exec_user_id):
return HelperUsers.get_managed_roles(exec_user_id)
@staticmethod
def get_created_servers(exec_user_id):
return HelperServers.get_total_owned_servers(exec_user_id)
def update_user(self, user_id: str, user_data=None, user_crafty_data=None):
if user_crafty_data is None:
user_crafty_data = {}

View File

@ -40,10 +40,6 @@ class HelperRoles:
def get_all_roles():
return Roles.select()
@staticmethod
def get_managed_roles(exec_user_id):
return Roles.select().where(Roles.manager == exec_user_id)
@staticmethod
def get_all_role_ids() -> t.List[int]:
return [role.role_id for role in Roles.select(Roles.role_id).execute()]

View File

@ -145,6 +145,11 @@ class HelperUsers:
user_query = Users.select().where(Users.manager == exec_user_id)
return user_query
@staticmethod
def get_managed_roles(exec_user_id):
roles_query = Roles.select().where(Roles.manager == exec_user_id)
return roles_query
@staticmethod
def get_user(user_id):
if user_id == 0: