diff --git a/tasks.py b/tasks.py index b72187f22b2003cb22e8e739128225b442ba3035..d454c14801fb3560105b16a295b7bd7b95ec8aeb 100644 --- a/tasks.py +++ b/tasks.py @@ -301,10 +301,16 @@ def parse_protocol_async_inner(protocol, encoded_kwargs): db.session.add(todo) db.session.commit() todo.protocols.append(protocol) - todo.state = field_state - todo.date = field_date - todo.who = who - todo.description = what + is_newest_protocol = True + for other_protocol in todo.protocols: + if other_protocol.date > protocol.date: + is_newest_protocol = False + break + if is_newest_protocol: + todo.state = field_state + todo.date = field_date + todo.who = who + todo.description = what db.session.commit() todo_tag.todo = todo # Decisions