diff --git a/dispatcher/backend/src/routes/schedules/schedule.py b/dispatcher/backend/src/routes/schedules/schedule.py index cd823321..1502a89d 100644 --- a/dispatcher/backend/src/routes/schedules/schedule.py +++ b/dispatcher/backend/src/routes/schedules/schedule.py @@ -1,4 +1,5 @@ import base64 +import copy import logging from http import HTTPStatus @@ -168,7 +169,9 @@ def get(self, token: AccessToken.Payload, session: so.Session): """Return all schedules backup""" def dump(schedule): - payload = ScheduleFullSchema(exclude=("most_recent_task",)).dump(schedule) + payload = copy.deepcopy( + ScheduleFullSchema(exclude=("most_recent_task",)).dump(schedule) + ) if not token or not token.get_permission("schedules", "update"): payload["notification"] = None @@ -177,7 +180,7 @@ def dump(schedule): return payload stmt = sa.select(dbm.Schedule).order_by(dbm.Schedule.name) - return jsonify( + result = jsonify( list( map( dump, @@ -186,6 +189,11 @@ def dump(schedule): ) ) + if session.new or session.dirty or session.deleted: + raise BadRequest("Unexpected modifications occured") + + return result + class ScheduleRoute(BaseRoute): rule = "/"