Fix enabling/disabling schedules from schedule list
What does this MR do and why?
Currently enabling/disabling schedules from the schedules list will not work. This is due to an improper check of a key that will not exist in the json payload. This MR checks for the key before trying to use it.
Screenshots or screen recordings
HTTPServerRequest(protocol='https', host='127.0.0.1:8443', method='PATCH', uri='/api/v2/servers/1/tasks/1', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "C:\Users\username\OneDrive\Documents\crafty-4\venv\lib\site-packages\tornado\web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "C:\Users\username\OneDrive\Documents\crafty-4\app\classes\web\routes\api\servers\server\tasks\task\index.py", line 139, in patch
if data["cron_string"] != "" and not croniter.is_valid(data["cron_string"]):
KeyError: 'cron_string'
How to set up and validate locally
Go to the schedules page where they are all listed. Try toggling them on or off. The notification will not pop up and after a refresh they will be back to the startup state.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
Have you checked this doesn't interfere/conflict/duplicate someone elses work? -
Have you fully tested your changes? -
Have you resolved any lint issues? -
Have you assigned a reviewer? -
Have you applied correct labels?
Edited by Andrew