mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Refactor managed roles to users controller/model
This commit is contained in:
parent
31b75b1c50
commit
245d64ca45
@ -67,10 +67,6 @@ class RolesController:
|
|||||||
def add_role(role_name, manager):
|
def add_role(role_name, manager):
|
||||||
return HelperRoles.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):
|
class RoleServerJsonType(t.TypedDict):
|
||||||
server_id: t.Union[str, int]
|
server_id: t.Union[str, int]
|
||||||
permissions: str
|
permissions: str
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import typing as t
|
import typing as t
|
||||||
|
from app.classes.models.servers import HelperServers
|
||||||
|
|
||||||
from app.classes.models.users import HelperUsers
|
from app.classes.models.users import HelperUsers
|
||||||
from app.classes.models.roles import HelperRoles
|
from app.classes.models.roles import HelperRoles
|
||||||
@ -137,6 +138,14 @@ class UsersController:
|
|||||||
def get_managed_users(exec_user_id):
|
def get_managed_users(exec_user_id):
|
||||||
return HelperUsers.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):
|
def update_user(self, user_id: str, user_data=None, user_crafty_data=None):
|
||||||
if user_crafty_data is None:
|
if user_crafty_data is None:
|
||||||
user_crafty_data = {}
|
user_crafty_data = {}
|
||||||
|
@ -40,10 +40,6 @@ class HelperRoles:
|
|||||||
def get_all_roles():
|
def get_all_roles():
|
||||||
return Roles.select()
|
return Roles.select()
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_managed_roles(exec_user_id):
|
|
||||||
return Roles.select().where(Roles.manager == exec_user_id)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_all_role_ids() -> t.List[int]:
|
def get_all_role_ids() -> t.List[int]:
|
||||||
return [role.role_id for role in Roles.select(Roles.role_id).execute()]
|
return [role.role_id for role in Roles.select(Roles.role_id).execute()]
|
||||||
|
@ -145,6 +145,11 @@ class HelperUsers:
|
|||||||
user_query = Users.select().where(Users.manager == exec_user_id)
|
user_query = Users.select().where(Users.manager == exec_user_id)
|
||||||
return user_query
|
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
|
@staticmethod
|
||||||
def get_user(user_id):
|
def get_user(user_id):
|
||||||
if user_id == 0:
|
if user_id == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user