Skip to content
Snippets Groups Projects
Commit baeab64f authored by Administrator's avatar Administrator
Browse files

Reuse the old todo-id when recompiling a protocol

parent 7fe2bb97
No related branches found
No related tags found
No related merge requests found
...@@ -143,11 +143,15 @@ def parse_protocol_async_inner(protocol, encoded_kwargs): ...@@ -143,11 +143,15 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
db.session.commit() db.session.commit()
return return
# todos # todos
old_todo_number_map = {}
for todo in protocol.todos:
old_todo_number_map[todo.description] = todo.get_id()
protocol.delete_orphan_todos() protocol.delete_orphan_todos()
db.session.commit() db.session.commit()
old_todos = list(protocol.todos) old_todos = list(protocol.todos)
for todo in old_todos: for todo in old_todos:
protocol.todos.remove(todo) protocol.todos.remove(todo)
print(old_todo_number_map)
db.session.commit() db.session.commit()
tags = tree.get_tags() tags = tree.get_tags()
todo_tags = [tag for tag in tags if tag.name == "todo"] todo_tags = [tag for tag in tags if tag.name == "todo"]
...@@ -225,6 +229,12 @@ def parse_protocol_async_inner(protocol, encoded_kwargs): ...@@ -225,6 +229,12 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
db.session.add(error) db.session.add(error)
db.session.commit() db.session.commit()
return return
if todo is None and field_id is None and what in old_todo_number_map:
todo = Todo(type_id=protocol.protocoltype.id,
who=who, description=what, state=field_state,
date=field_date, number=old_todo_number_map[what])
db.session.add(todo)
db.session.commit()
if todo is None: if todo is None:
protocol_key = protocol.get_identifier() protocol_key = protocol.get_identifier()
old_candidates = OldTodo.query.filter( old_candidates = OldTodo.query.filter(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment