From 28bd91c52ce1eab2b26793097e0d9cabc3c33c64 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 16 Jan 2024 03:30:57 +0100
Subject: [PATCH] Various small fixes.

---
 ledger.py                |  2 +-
 todo.py                  |  4 ++--
 todo_templates/task.html | 12 ++++++------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/ledger.py b/ledger.py
index a26ca0f..46035bc 100755
--- a/ledger.py
+++ b/ledger.py
@@ -1248,7 +1248,7 @@ class LedgerHandler(PlomHandler):
         elif prefix + '/edit' == parsed_url.path:
             index = int(postvars['index'][0])
             edit_mode = postvars['edit_mode'][0]
-            validate = submit_button in {'save', 'copy', 'check'}
+            validate = submit_button in {'update', 'add', 'copy', 'check'}
             starts_at = '?' if index == -1 else db.bookings[index].starts_at
             if 'textarea' == edit_mode:
                 lines = [LedgerTextLine(line) for line in postvars['booking'][0].rstrip().split('\n')]
diff --git a/todo.py b/todo.py
index 171514f..a4d7da0 100644
--- a/todo.py
+++ b/todo.py
@@ -483,7 +483,7 @@ class TodoDB(PlomDB):
 
     def add_task(self, id_=None, dict_source=None, return_id=False):
         id_ = id_ if id_ else str(uuid4())
-        t = Task.from_dict(self, dict_source, id_) if dict_source else Task(self, id)
+        t = Task.from_dict(self, dict_source, id_) if dict_source else Task(self, id_)
         self.tasks[id_] = t
         if return_id:
             return id_, t
@@ -707,7 +707,7 @@ class TodoDB(PlomDB):
 
     def show_task(self, id_, return_to='', search=''):
         task = self.tasks[id_] if id_ else self.add_task()
-        selected = id_ in self.selected_day.todos.keys()
+        selected = task.id_ in self.selected_day.todos.keys()
         linked_tasks = [self.tasks[l] for l in task.links]
         filtered_tasks = [t for t in self.tasks.values() if t.visible and t != self and (t not in linked_tasks) and (len(search) == 0 or t.matches(search))] 
         return j2env.get_template('task.html').render(
diff --git a/todo_templates/task.html b/todo_templates/task.html
index 05a6611..85347ef 100644
--- a/todo_templates/task.html
+++ b/todo_templates/task.html
@@ -28,19 +28,19 @@ add: <input name="joined_tags" type="text" value="" ><br />
 <tr><th>children</th>
 <td>
 <table>
-{% for task in linked_tasks %}
+{% for subtask in linked_tasks %}
 <tr>
-<td><input name="link_task" type="checkbox" value="{{task.id_}}" checked/></td>
-<td><a href="task?id={{task.id_}}">{{task.title}}</a></td>
+<td><input name="link_task" type="checkbox" value="{{subtask.id_}}" checked/></td>
+<td><a href="task?id={{subtask.id_}}">{{subtask.title}}</a></td>
 </tr>
 {% endfor %}
 <tr>
 <th colspan=2>---</th>
 </tr>
-{% for task in filtered_tasks %}
+{% for subtask in filtered_tasks %}
 <tr>
-<td><input name="link_task" type="checkbox" value="{{task.id_}}"/></td>
-<td><a href="task?id={{task.id_}}">{{task.title}}</a></td>
+<td><input name="link_task" type="checkbox" value="{{subtask.id_}}"/></td>
+<td><a href="task?id={{subtask.id_}}">{{subtask.title}}</a></td>
 </tr>
 {% endfor %}
 </table>
-- 
2.30.2