home · contact · privacy
Enable deletion of Todos.
[plomtask] / plomtask / http.py
index 800193ce49ab7c90a1ff00add0a9d3fd32cf8b4e..2b41db82e00e5d4cfac862161fb352607d09dfbb 100644 (file)
@@ -212,6 +212,10 @@ class TaskHandler(BaseHTTPRequestHandler):
     def do_POST_todo(self) -> str:
         """Update Todo and its children."""
         id_ = self.params.get_int('id')
+        for _ in self.form_data.get_all_str('delete'):
+            todo = Todo .by_id(self.conn, id_)
+            todo.remove(self.conn)
+            return '/'
         todo = Todo.by_id(self.conn, id_)
         adopted_child_ids = self.form_data.get_all_int('adopt')
         for child in todo.children:
@@ -273,6 +277,10 @@ class TaskHandler(BaseHTTPRequestHandler):
     def do_POST_condition(self) -> str:
         """Update/insert Condition of ?id= and fields defined in postvars."""
         id_ = self.params.get_int_or_none('id')
+        for _ in self.form_data.get_all_str('delete'):
+            condition = Condition.by_id(self.conn, id_)
+            condition.remove(self.conn)
+            return '/conditions'
         condition = Condition.by_id(self.conn, id_, create=True)
         condition.title.set(self.form_data.get_str('title'))
         condition.description.set(self.form_data.get_str('description'))