X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=plomtask%2Fhttp.py;fp=plomtask%2Fhttp.py;h=d411124c475f9378e3622083eb9bb5fc706ea14e;hb=4c0b3ff23b3d9fc526dfaa4803eb167d64c32181;hp=a1f85fdd6519dabefa9acc795d43d8720c5024af;hpb=bdb37bdbfdc46a64631c0fb97d0d86540076165e;p=plomtask diff --git a/plomtask/http.py b/plomtask/http.py index a1f85fd..d411124 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -196,14 +196,21 @@ class TaskHandler(BaseHTTPRequestHandler): day = Day.by_id(self.conn, date, create=True) day.comment = self.form_data.get_str('comment') day.save(self.conn) - existing_todos = Todo.by_date(self.conn, date) + new_todos = [] for process_id in self.form_data.get_all_int('new_todo'): process = Process.by_id(self.conn, process_id) todo = Todo(None, process, False, day.date) todo.save(self.conn) - todo.adopt_from(existing_todos) - todo.make_missing_children(self.conn) - todo.save(self.conn) + new_todos += [todo] + adopted = True + while adopted: + adopted = False + existing_todos = Todo.by_date(self.conn, date) + for todo in new_todos: + if todo.adopt_from(existing_todos): + adopted = True + todo.make_missing_children(self.conn) + todo.save(self.conn) for todo_id in self.form_data.get_all_int('done'): todo = Todo.by_id(self.conn, todo_id) todo.is_done = True