Minor changes in light of
@@ -137,12 +137,12 @@ async def _check_schedule_post_parameters(data, curr_value=None):
# Raise error if day and time are missing for schedule_type = TIMED
if _schedule.get('schedule_type') == Schedule.Type.TIMED:
- if not _schedule.get('schedule_day') or not _schedule.get('schedule_time'):
+ if not _schedule.get('schedule_day'):
_errors.append('Schedule day and time cannot be empty for TIMED schedule.')
- elif not isinstance(_schedule.get('schedule_day'), int):
- _errors.append('Day must be an integer.')
- elif not isinstance(_schedule.get('schedule_time'), int):
- _errors.append('Time must be an integer.')
+ elif not isinstance(_schedule.get('schedule_day'), int) or (_schedule.get('schedule_day') < 1 or _schedule.get('schedule_day') > 7):
+ _errors.append('Day must be an integer and in range 1-7.')
+ elif not isinstance(_schedule.get('schedule_time'), int) or (_schedule.get('schedule_time') < 0 or _schedule.get('schedule_time') > 86399):
+ _errors.append('Time must be an integer and in range 0-86399.')
# Raise error if repeat is missing or is non integers
if _schedule.get('schedule_type') == Schedule.Type.INTERVAL:
@@ -372,8 +372,8 @@ async def update_schedule(request):
curr_value['schedule_process_name'] = sch.process_name
curr_value['schedule_name'] = sch.name
curr_value['schedule_type'] = sch.schedule_type
- curr_value['schedule_repeat'] = sch.repeat
- curr_value['schedule_time'] = sch.time
+ curr_value['schedule_repeat'] = sch.repeat.total_seconds() if sch.repeat else 0
+ curr_value['schedule_time'] = (sch.time.hour * 60 * 60 + sch.time.minute * 60 + sch.time.second) if sch.time else 0
curr_value['schedule_day'] = sch.day
curr_value['schedule_exclusive'] = sch.exclusive
