Better use of functions and objects

This commit is contained in:
Silversthorn 2022-07-16 10:06:49 +02:00
parent 9f30ca3931
commit ee2c2f8bb1

View File

@ -539,11 +539,7 @@ class PanelHandler(BaseHandler):
except Exception as e: except Exception as e:
logger.error(f"Failed to get server waiting to start: {e}") logger.error(f"Failed to get server waiting to start: {e}")
page_data["waiting_start"] = False page_data["waiting_start"] = False
page_data[ page_data["get_players"] = server.get_server_players()
"get_players"
] = lambda: self.controller.servers.get_server_instance_by_id(
server_id
).get_server_players()
page_data["active_link"] = subpage page_data["active_link"] = subpage
page_data["permissions"] = { page_data["permissions"] = {
"Commands": EnumPermissionsServer.COMMANDS, "Commands": EnumPermissionsServer.COMMANDS,
@ -879,11 +875,7 @@ class PanelHandler(BaseHandler):
page_data["schedules"] = HelpersManagement.get_schedules_by_server( page_data["schedules"] = HelpersManagement.get_schedules_by_server(
server_id server_id
) )
page_data[ page_data["get_players"] = server_obj.get_server_players()
"get_players"
] = lambda: self.controller.servers.get_server_instance_by_id(
server_id
).get_server_players()
page_data["active_link"] = "schedules" page_data["active_link"] = "schedules"
page_data["permissions"] = { page_data["permissions"] = {
"Commands": EnumPermissionsServer.COMMANDS, "Commands": EnumPermissionsServer.COMMANDS,
@ -949,11 +941,7 @@ class PanelHandler(BaseHandler):
self.redirect("/panel/error?error=Invalid Schedule ID") self.redirect("/panel/error?error=Invalid Schedule ID")
return return
schedule = self.controller.management.get_scheduled_task_model(sch_id) schedule = self.controller.management.get_scheduled_task_model(sch_id)
page_data[ page_data["get_players"] = server_obj.get_server_players()
"get_players"
] = lambda: self.controller.servers.get_server_instance_by_id(
server_id
).get_server_players()
page_data["active_link"] = "schedules" page_data["active_link"] = "schedules"
page_data["permissions"] = { page_data["permissions"] = {
"Commands": EnumPermissionsServer.COMMANDS, "Commands": EnumPermissionsServer.COMMANDS,