From 8095b998689fcf1d2a78da0775a3ac31b10beb1b Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Mon, 24 Jul 2017 11:13:05 +0200
Subject: [PATCH] Do not update todos on recompiling old protocols

---
 tasks.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tasks.py b/tasks.py
index b72187f..d454c14 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
-- 
GitLab