mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Trying to fix stuff
This commit is contained in:
parent
18bf7ebd01
commit
f597a26e5b
@ -107,9 +107,7 @@ class ServerPermsController:
|
||||
)
|
||||
|
||||
for server in authorized_servers:
|
||||
srv: Server = ServersController().get_server_instance_by_id(
|
||||
server.get("server_id")
|
||||
)
|
||||
srv = ServersController().get_server_instance_by_id(server.get("server_id"))
|
||||
latest = srv.stats_helper.get_latest_server_stats()
|
||||
server_data.append(
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ class ServersController(metaclass=Singleton):
|
||||
return False
|
||||
|
||||
def refresh_server_settings(self, server_id: int):
|
||||
server_obj: Server = self.get_server_data_by_id(server_id)
|
||||
server_obj = self.get_server_instance_by_id(server_id)
|
||||
server_obj.reload_server_settings()
|
||||
|
||||
@staticmethod
|
||||
@ -287,7 +287,7 @@ class ServersController(metaclass=Singleton):
|
||||
@staticmethod
|
||||
def get_authorized_servers_stats_api_key(api_key: ApiKeys):
|
||||
server_data = []
|
||||
authorized_servers = ServersController.get_authorized_servers(
|
||||
authorized_servers = ServersController().get_authorized_servers(
|
||||
api_key.user_id # TODO: API key authorized servers?
|
||||
)
|
||||
|
||||
@ -376,10 +376,13 @@ class ServersController(metaclass=Singleton):
|
||||
logger.warning(f"Unable to find server object for server id {server_id}")
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def list_defined_servers():
|
||||
servers = HelperServers.get_all_defined_servers()
|
||||
return servers
|
||||
def list_defined_servers(self):
|
||||
defined_servers = []
|
||||
for server in self.servers_list:
|
||||
defined_servers.append(
|
||||
self.get_server_instance_by_id(server.get("server_id"))
|
||||
)
|
||||
return defined_servers
|
||||
|
||||
@staticmethod
|
||||
def get_all_server_ids() -> t.List[int]:
|
||||
|
@ -123,17 +123,11 @@ class HelperServerStats:
|
||||
server_data = []
|
||||
try:
|
||||
for server in servers:
|
||||
latest = (
|
||||
ServerStats.select()
|
||||
.where(ServerStats.server_id == server.get("server_id"))
|
||||
.order_by(ServerStats.created.desc())
|
||||
.limit(1)
|
||||
)
|
||||
latest._database = self.database
|
||||
latest = self.get_latest_server_stats()
|
||||
server_data.append(
|
||||
{
|
||||
"server_data": server,
|
||||
"stats": DatabaseShortcuts.get_data_obj(latest),
|
||||
"stats": latest,
|
||||
"user_command_permission": True,
|
||||
}
|
||||
)
|
||||
|
@ -180,7 +180,7 @@ class BaseHandler(tornado.web.RequestHandler):
|
||||
|
||||
exec_user_role = set()
|
||||
if superuser:
|
||||
authorized_servers = self.controller.servers.list_defined_servers()
|
||||
authorized_servers = self.controller.servers.get_all_defined_servers()
|
||||
exec_user_role.add("Super User")
|
||||
exec_user_crafty_permissions = (
|
||||
self.controller.crafty_perms.list_defined_crafty_permissions()
|
||||
|
@ -41,7 +41,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
def get_role_servers(self) -> t.List[RolesController.RoleServerJsonType]:
|
||||
servers = []
|
||||
for server in self.controller.servers.list_defined_servers():
|
||||
for server in self.controller.servers.get_all_defined_servers():
|
||||
argument = self.get_argument(f"server_{server['server_id']}_access", "0")
|
||||
if argument == "0":
|
||||
continue
|
||||
@ -269,6 +269,7 @@ class PanelHandler(BaseHandler):
|
||||
page_servers.append(
|
||||
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||
)
|
||||
|
||||
for server_id in user_order[:]:
|
||||
# remove IDs in list that user no longer has access to
|
||||
if str(server_id) not in server_ids:
|
||||
@ -801,7 +802,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
page_data["roles_all"] = self.controller.roles.get_all_roles()
|
||||
page_data["servers"] = []
|
||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
||||
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||
page_data["role-servers"] = []
|
||||
page_data[
|
||||
"permissions_all"
|
||||
@ -979,7 +980,7 @@ class PanelHandler(BaseHandler):
|
||||
page_data["servers"] = set()
|
||||
page_data["role-servers"] = page_role_servers
|
||||
page_data["roles_all"] = self.controller.roles.get_all_roles()
|
||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
||||
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||
page_data["superuser"] = superuser
|
||||
page_data[
|
||||
"permissions_all"
|
||||
@ -1107,7 +1108,7 @@ class PanelHandler(BaseHandler):
|
||||
)
|
||||
return
|
||||
|
||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
||||
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||
page_data[
|
||||
"permissions_all"
|
||||
] = self.controller.server_perms.list_defined_permissions()
|
||||
@ -1119,7 +1120,7 @@ class PanelHandler(BaseHandler):
|
||||
page_data["new_role"] = False
|
||||
role_id = self.get_argument("id", None)
|
||||
page_data["role"] = self.controller.roles.get_role_with_servers(role_id)
|
||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
||||
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||
page_data[
|
||||
"permissions_all"
|
||||
] = self.controller.server_perms.list_defined_permissions()
|
||||
|
@ -10,6 +10,7 @@ import requests
|
||||
from app.classes.models.crafty_permissions import EnumPermissionsCrafty
|
||||
from app.classes.shared.helpers import Helpers
|
||||
from app.classes.shared.file_helpers import FileHelpers
|
||||
from app.classes.shared.main_models import DatabaseShortcuts
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -52,6 +53,14 @@ class ServerHandler(BaseHandler):
|
||||
exec_user_role.add(role["role_name"])
|
||||
list_roles.append(self.controller.roles.get_role(role["role_id"]))
|
||||
|
||||
page_servers = []
|
||||
for server in defined_servers:
|
||||
if server not in page_servers:
|
||||
page_servers.append(
|
||||
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||
)
|
||||
defined_servers = page_servers
|
||||
|
||||
template = "public/404.html"
|
||||
|
||||
page_data = {
|
||||
|
Loading…
Reference in New Issue
Block a user