diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index 8360f48f..44d48409 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -161,7 +161,12 @@ class TasksManager: for schedule in schedules: if schedule.cron_string != "": cron = schedule.cron_string.split(' ') - self.scheduler.add_job(management_helper.add_command, 'cron', minute = cron[0], hour = cron[1], day = cron[2], month = cron[3], day_of_week = cron[4], id=str(schedule.schedule_id), args=[schedule.server_id, self.users_controller.get_id_by_name('system'), '127.0.0.1', schedule.command]) + try: + self.scheduler.add_job(management_helper.add_command, 'cron', minute = cron[0], hour = cron[1], day = cron[2], month = cron[3], day_of_week = cron[4], id=str(schedule.schedule_id), args=[schedule.server_id, self.users_controller.get_id_by_name('system'), '127.0.0.1', schedule.command]) + except Exception as e: + console.error("Failed to schedule task with error: {}.".format(e)) + console.warning("Removing failed task from DB.") + management_helper.delete_scheduled_task(schedule.schedule_id) else: if schedule.interval_type == 'hours': self.scheduler.add_job(management_helper.add_command, 'cron', minute = 0, hour = '*/'+str(schedule.interval), id=str(schedule.schedule_id), args=[schedule.server_id, self.users_controller.get_id_by_name('system'), '127.0.0.1', schedule.command]) @@ -186,7 +191,7 @@ class TasksManager: self.scheduler.add_job(management_helper.add_command, 'cron', minute = cron[0], hour = cron[1], day = cron[2], month = cron[3], day_of_week = cron[4], id=str(sch_id), args=[job_data['server_id'], self.users_controller.get_id_by_name('system'), '127.0.0.1', job_data['command']]) except Exception as e: console.error("Failed to schedule task with error: {}.".format(e)) - console.info("Removing failed task from DB.") + console.warning("Removing failed task from DB.") management_helper.delete_scheduled_task(sch_id) else: if job_data['interval_type'] == 'hours': diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 83e177e6..4942936a 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -559,7 +559,6 @@ class PanelHandler(BaseHandler): 'Players': Enum_Permissions_Server.Players, } page_data['user_permissions'] = self.controller.server_perms.get_user_id_permissions_list(exec_user["user_id"], server_id) - exec_user_server_permissions = self.controller.server_perms.get_user_permissions_list(exec_user["user_id"], server_id) page_data['server_data'] = self.controller.servers.get_server_data_by_id(server_id) page_data['server_stats'] = self.controller.servers.get_server_stats_by_id(server_id) page_data['new_schedule'] = True @@ -577,7 +576,7 @@ class PanelHandler(BaseHandler): page_data['schedule']['difficulty'] = "basic" page_data['schedule']['interval_type'] = 'days' - if not Enum_Permissions_Server.Schedule in exec_user_server_permissions: + if not Enum_Permissions_Server.Schedule in page_data['user_permissions']: if not superuser: self.redirect("/panel/error?error=Unauthorized access To Scheduled Tasks") return @@ -601,7 +600,6 @@ class PanelHandler(BaseHandler): 'Players': Enum_Permissions_Server.Players, } page_data['user_permissions'] = self.controller.server_perms.get_user_id_permissions_list(exec_user["user_id"], server_id) - exec_user_server_permissions = self.controller.server_perms.get_user_permissions_list(exec_user["user_id"], server_id) page_data['server_data'] = self.controller.servers.get_server_data_by_id(server_id) page_data['server_stats'] = self.controller.servers.get_server_stats_by_id(server_id) page_data['new_schedule'] = False @@ -629,7 +627,7 @@ class PanelHandler(BaseHandler): if sch_id == None or server_id == None: self.redirect("/panel/error?error=Invalid server ID or Schedule ID") - if not Enum_Permissions_Server.Schedule in exec_user_server_permissions: + if not Enum_Permissions_Server.Schedule in page_data['user_permissions']: if not superuser: self.redirect("/panel/error?error=Unauthorized access To Scheduled Tasks") return diff --git a/app/frontend/templates/panel/server_schedule_edit.html b/app/frontend/templates/panel/server_schedule_edit.html index 4ed22396..5d3de6d3 100644 --- a/app/frontend/templates/panel/server_schedule_edit.html +++ b/app/frontend/templates/panel/server_schedule_edit.html @@ -203,9 +203,9 @@ try{ }catch{ console.log("no element named {{ data['schedule']['action'] }}") } + ifDays(); yesnoCheck(); basicAdvanced(); - ifDays(); if("{{ data['schedule']['enabled'] }}" == 'True'){ document.getElementById('enabled').checked = true; }else{