home · contact · privacy
Add Todo.title shortcut to Todo.process.title for more template refactoring.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 18 May 2024 01:40:54 +0000 (03:40 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 18 May 2024 01:40:54 +0000 (03:40 +0200)
plomtask/todos.py
templates/day.html
templates/process.html
templates/todo.html

index a9bd94c7c0afa6d27e584f1e44bfa318012f93e5..0313e559ee25db4360a14e53cadd31e23a52dda7 100644 (file)
@@ -5,6 +5,7 @@ from typing import Any
 from sqlite3 import Row
 from plomtask.db import DatabaseConnection, BaseModel
 from plomtask.processes import Process
+from plomtask.versioned_attributes import VersionedAttribute
 from plomtask.conditions import Condition, ConditionsRelations
 from plomtask.exceptions import (NotFoundException, BadFormatException,
                                  HandledException)
@@ -128,6 +129,11 @@ class Todo(BaseModel[int], ConditionsRelations):
                 for condition in self.disables:
                     condition.is_active = False
 
+    @property
+    def title(self) -> VersionedAttribute:
+        """Shortcut to .process.title."""
+        return self.process.title
+
     def adopt_from(self, todos: list[Todo]) -> bool:
         """As far as possible, fill unsatisfied dependencies from todos."""
         adopted = False
index da5e17ae91d239e4d95a3893c5f34d31837b3ebd..ce16f28179588d367680dd80c2123459f4942251 100644 (file)
@@ -177,5 +177,5 @@ add todo: <input name="new_todo" list="processes" autocomplete="off" />
 
 </form>
 
-{{ macros.datalist_of_direct_titles("processes", processes) }}
+{{ macros.datalist_of_titles("processes", processes) }}
 {% endblock %}
index 41f811705eef7223efb7d92591b4c0431c629c03..5aebe53aaecf8f49b6e8440da36c5987c0e24d3e 100644 (file)
@@ -95,6 +95,6 @@ add: <input name="new_top_step" list="step_candidates" autocomplete="off" />
 {{ macros.edit_buttons() }}
 </form>
 
-{{ macros.datalist_of_direct_titles("condition_candidates", condition_candidates) }}
-{{ macros.datalist_of_direct_titles("step_candidates", step_candidates) }}
+{{ macros.datalist_of_titles("condition_candidates", condition_candidates) }}
+{{ macros.datalist_of_titles("step_candidates", step_candidates) }}
 {% endblock %}
index d3957af79545e5492fc8217d6977cfb91046b886..71f2e1b06d95bf325937dc65d2207c955c4f1805 100644 (file)
 
 <tr>
 <th>children</th>
-<td>
-<table>
-{% for child in todo.children %}
-<tr>
-<td><input type="checkbox" name="adopt" value="{{child.id_}}" checked /></td>
-<td><a href="todo?id={{child.id_}}">{{child.process.title.newest|e}}</a></td>
-</tr>
-{% endfor %}
-</table>
-adopt: <input name="adopt" list="todo_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("adopt", todo.children, "adopt", "todo_candidates", "adopt") }}</td>
 </tr>
 
 </table>
 {{ macros.edit_buttons() }}
 </form>
 
-{{ macros.datalist_of_direct_titles("condition_candidates", condition_candidates) }}
-{{ macros.datalist_of_indirect_titles("todo_candidates", todo_candidates) }}
+{{ macros.datalist_of_titles("condition_candidates", condition_candidates) }}
+{{ macros.datalist_of_titles("todo_candidates", todo_candidates) }}
 {% endblock %}