home · contact · privacy
On posting a new Todo to a Day, auto-adopt existing ones per its Process' .explicit_s...
[plomtask] / plomtask / http.py
index 140f6bcfb16dbe89222b324d7e06bd7545f2f0f3..64cc6f95871174c71badbf495f9f3dfe56f74cc1 100644 (file)
@@ -195,10 +195,17 @@ 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)
         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)
+            for step in todo.process.explicit_steps:
+                for t in [t for t in existing_todos
+                          if t.process.id_ == step.step_process_id]:
+                    todo.add_child(t)
+                    break
+            todo.save(self.conn)
 
     def do_POST_todo(self) -> None:
         """Update Todo and its children."""