From e06d3b744f88b2976399b0cbe08b526bb7e88907 Mon Sep 17 00:00:00 2001
From: Christian Heller
Date: Wed, 15 May 2024 08:32:13 +0200
Subject: [PATCH] Add POSTing of Todo.comment in Day view.
---
plomtask/http.py | 7 +++++--
templates/day.html | 8 ++++----
tests/days.py | 4 ++--
tests/todos.py | 24 ++++++++++++------------
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/plomtask/http.py b/plomtask/http.py
index cf3288a..15f8376 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -194,7 +194,7 @@ class TaskHandler(BaseHTTPRequestHandler):
"""Update or insert Day of date and Todos mapped to it."""
date = self.params.get_str('date')
day = Day.by_id(self.conn, date, create=True)
- day.comment = self.form_data.get_str('comment')
+ day.comment = self.form_data.get_str('day_comment')
day.save(self.conn)
new_todos = []
for process_id in self.form_data.get_all_int('new_todo'):
@@ -212,9 +212,12 @@ class TaskHandler(BaseHTTPRequestHandler):
todo.make_missing_children(self.conn)
todo.save(self.conn)
done_ids = self.form_data.get_all_int('done')
- for todo_id in self.form_data.get_all_int('todo_id'):
+ comments = self.form_data.get_all_str('comment')
+ for i, todo_id in enumerate(self.form_data.get_all_int('todo_id')):
todo = Todo.by_id(self.conn, todo_id)
todo.is_done = todo_id in done_ids
+ if len(comments) > 0:
+ todo.comment = comments[i]
todo.save(self.conn)
for condition in todo.enables:
condition.save(self.conn)
diff --git a/templates/day.html b/templates/day.html
index cd683da..b816f35 100644
--- a/templates/day.html
+++ b/templates/day.html
@@ -50,7 +50,7 @@ td.todo_line {
{% if condition in node.todo.enables %}+{% elif condition in node.todo.disables %}!{% endif %} |
{% endfor %}
- |
+ |
{% endif %}
@@ -71,7 +71,7 @@ td.todo_line {
{% if path|length > 0 and not path[-1].todo.is_done %}
-({% for path_node in path %}{{path_node.todo.process.title.newest|e}} <- {% endfor %})
+({% for path_node in path %}{{path_node.todo.process.title.newest|e}} <- {% endfor %})
|
@@ -82,7 +82,7 @@ td.todo_line {
{% for i in range(indent) %} {% endfor %} +
{% endif %}
-{% if node.seen %}({% endif %}{{node.todo.process.title.newest|e}}{% if node.seen %}){% endif %}
+{% if node.seen %}({% endif %}{{node.todo.process.title.newest|e}} {% if node.todo.comment|length > 0 %}[{{node.todo.comment|e}}]{% endif %}{% if node.seen %}){% endif %}
|
@@ -103,7 +103,7 @@ td.todo_line {
prev | next