Merge branch 'bug/schedule-disable' into 'dev'

Fix scheduled task disable

See merge request crafty-controller/crafty-4!478
This commit is contained in:
Iain Powrie 2022-10-05 21:09:05 +00:00
commit 7a81652395
3 changed files with 11 additions and 3 deletions

View File

@ -4,6 +4,7 @@
TBD
### Bug fixes
- Fix conditional issue with zip imports/uploads ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/476))
- Fix API Schedule updates ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/478))
### Tweaks
- Fix sidebar to not move when scrolling ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/475))
### Lang

View File

@ -436,7 +436,15 @@ class TasksManager:
and "cron_string" in job_data
and "interval_type" in job_data
):
return
if not "enabled" in job_data:
return
if job_data["enabled"] is True:
job_data = HelpersManagement.get_scheduled_task(sch_id)
job_data["server_id"] = job_data["server_id"]["server_id"]
else:
self.scheduler.remove_job(str(sch_id))
return
try:
if job_data["interval"] != "reaction":

View File

@ -4,7 +4,6 @@ import json
import logging
from jsonschema import ValidationError, validate
from app.classes.models.management import HelpersManagement
from app.classes.models.server_permissions import EnumPermissionsServer
from app.classes.web.base_api_handler import BaseApiHandler
@ -97,7 +96,7 @@ class ApiServersServerTasksTaskIndexHandler(BaseApiHandler):
if str(data.get("parent")) == str(task_id) and data.get("parent") is not None:
data["parent"] = None
HelpersManagement.update_scheduled_task(task_id, data)
self.tasks_manager.update_job(task_id, data)
self.controller.management.add_to_audit_log(
auth_data[4]["user_id"],