From: Christian Heller Date: Wed, 15 May 2024 02:37:08 +0000 (+0200) Subject: Re-introduce POSTing of Todo doneness on Day view. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/index.html?a=commitdiff_plain;h=206a9111fdc95fcb24ae4793a7536e1facf82b71;p=plomtask Re-introduce POSTing of Todo doneness on Day view. --- diff --git a/plomtask/http.py b/plomtask/http.py index d411124..cf3288a 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -211,9 +211,10 @@ class TaskHandler(BaseHTTPRequestHandler): adopted = True todo.make_missing_children(self.conn) todo.save(self.conn) - for todo_id in self.form_data.get_all_int('done'): + done_ids = self.form_data.get_all_int('done') + for todo_id in self.form_data.get_all_int('todo_id'): todo = Todo.by_id(self.conn, todo_id) - todo.is_done = True + todo.is_done = todo_id in done_ids todo.save(self.conn) for condition in todo.enables: condition.save(self.conn) diff --git a/templates/day.html b/templates/day.html index 167b703..cd683da 100644 --- a/templates/day.html +++ b/templates/day.html @@ -32,13 +32,14 @@ td.todo_line { {% macro show_node_undone(node, indent) %} {% if not node.todo.is_done %} + {% for condition in conditions_present %} {% if condition in node.todo.conditions %}{% if not condition.is_active %}O{% endif %}{% endif %} {% endfor %} -> - + {% for i in range(indent) %}  {% endfor %} + {% if node.seen %}({% endif %}{{node.todo.process.title.newest|e}}{% if node.seen %}){% endif %} diff --git a/tests/todos.py b/tests/todos.py index 5e9f4b8..0633547 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -357,6 +357,19 @@ class TestsWithServer(TestCaseWithServer): self.assertEqual(todo2.children, [todo1]) self.assertEqual(todo2.parents, []) + def test_do_POST_day_todo_doneness(self) -> None: + """Test multiple Todos can be posted to Day view.""" + form_data = self.post_process() + form_data = {'comment': '', 'new_todo': [1]} + self.check_post(form_data, '/day?date=2024-01-01', 302) + todo = Todo.by_date(self.db_conn, '2024-01-01')[0] + form_data = {'comment': '', 'todo_id': [1]} + self.check_post(form_data, '/day?date=2024-01-01', 302) + self.assertEqual(todo.is_done, False) + form_data = {'comment': '', 'todo_id': [1], 'done': [1]} + self.check_post(form_data, '/day?date=2024-01-01', 302) + self.assertEqual(todo.is_done, True) + def test_do_GET_todo(self) -> None: """Test GET /todo response codes.""" self.post_process()