home · contact · privacy
Display historical VersionedAttributes where it makes sense.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 30 May 2024 04:12:35 +0000 (06:12 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 30 May 2024 04:12:35 +0000 (06:12 +0200)
plomtask/http.py
plomtask/todos.py
plomtask/versioned_attributes.py
templates/_macros.html
templates/calendar.html
templates/day.html
templates/todo.html
templates/todos.html

index f6b17a076c6fa92455983b1198351cc486c79906..8255aa2469354f0f28f7c1fe907a2adc7dd781f0 100644 (file)
@@ -172,9 +172,9 @@ class TaskHandler(BaseHTTPRequestHandler):
         elif sort_by == '-doneness':
             todos.sort(key=lambda t: t.is_done, reverse=True)
         elif sort_by == 'process':
-            todos.sort(key=lambda t: t.process.title.newest)
+            todos.sort(key=lambda t: t.title_then)
         elif sort_by == '-process':
-            todos.sort(key=lambda t: t.process.title.newest, reverse=True)
+            todos.sort(key=lambda t: t.title_then, reverse=True)
         elif sort_by == 'comment':
             todos.sort(key=lambda t: t.comment)
         elif sort_by == '-comment':
@@ -182,7 +182,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         elif sort_by == '-date':
             todos.sort(key=lambda t: t.date, reverse=True)
         else:
-            todos.sort(key=lambda c: c.title.newest)
+            todos.sort(key=lambda t: t.date)
         return {'start': start, 'end': end, 'process_id': process_id,
                 'comment_pattern': comment_pattern, 'todos': todos,
                 'all_processes': Process.all(self.conn), 'sort_by': sort_by}
@@ -256,13 +256,13 @@ class TaskHandler(BaseHTTPRequestHandler):
         processes = Process.matching(self.conn, pattern)
         sort_by = self.params.get_str('sort_by')
         if sort_by == 'steps':
-            processes.sort(key=lambda c: len(c.explicit_steps))
+            processes.sort(key=lambda p: len(p.explicit_steps))
         elif sort_by == '-steps':
-            processes.sort(key=lambda c: len(c.explicit_steps), reverse=True)
+            processes.sort(key=lambda p: len(p.explicit_steps), reverse=True)
         elif sort_by == '-title':
-            processes.sort(key=lambda c: c.title.newest, reverse=True)
+            processes.sort(key=lambda p: p.title.newest, reverse=True)
         else:
-            processes.sort(key=lambda c: c.title.newest)
+            processes.sort(key=lambda p: p.title.newest)
         return {'processes': processes, 'sort_by': sort_by, 'pattern': pattern}
 
     def do_POST(self) -> None:
index 712609aa8d81fdbe4f194a244ab6927224ee67ca..ffef677d29e652ad82d18e2d2c9f7b848e73a698 100644 (file)
@@ -182,6 +182,20 @@ class Todo(BaseModel[int], ConditionsRelations):
         """Shortcut to .process.title."""
         return self.process.title
 
+    @property
+    def title_then(self) -> str:
+        """Shortcut to .process.title.at(self.date)"""
+        title_then = self.process.title.at(self.date)
+        assert isinstance(title_then, str)
+        return title_then
+
+    @property
+    def effort_then(self) -> float:
+        """Shortcut to .process.effort.at(self.date)"""
+        effort_then = self.process.effort.at(self.date)
+        assert isinstance(effort_then, float)
+        return effort_then
+
     def adopt_from(self, todos: list[Todo]) -> bool:
         """As far as possible, fill unsatisfied dependencies from todos."""
         adopted = False
index 1810a318d3781c96626f40d679c53db42072403d..b3442d7df1030b72b2990a21e12ffa12302aa9d1 100644 (file)
@@ -51,6 +51,8 @@ class VersionedAttribute:
 
     def at(self, queried_time: str) -> str | float:
         """Retrieve value of timestamp nearest queried_time from the past."""
+        if len(queried_time) == 10:
+            queried_time += ' 23:59:59.999'
         sorted_timestamps = sorted(self.history.keys())
         if 0 == len(sorted_timestamps):
             return self.default
index 25d94c58ce72a0a52f483c3251a30f9c3496ab51..b1f0104e134363bc9b8dcd24f6d6066d08996f00 100644 (file)
@@ -17,7 +17,7 @@
 
 
 
-{% macro simple_checkbox_table(title, items, type_name, list_name, add_string="add") %}
+{% macro simple_checkbox_table(title, items, type_name, list_name, add_string="add", historical=false) %}
 <table>
 {% for item in items %}
 <tr>
@@ -25,7 +25,7 @@
 <input type="checkbox" name="{{title}}" value="{{item.id_}}" checked />
 </td>
 <td>
-<a href="{{type_name}}?id={{item.id_}}">{{item.title.newest|e}}</a>
+<a href="{{type_name}}?id={{item.id_}}">{% if historical %}{{item.title_then}}{% else %}{{item.title.newest|e}}{% endif %}</a>
 </td>
 </tr>
 {% endfor %}
index 77242037982762100a20e21bf0d8b453877c7fe3..4d672421329c95208cb1ca5050130c78065bfe9b 100644 (file)
@@ -52,7 +52,7 @@ to <input name="end" value="{{end}}" />
 {% for todo in day.calendarized_todos %}
 <tr>
 <td>[{% if todo.is_done %}X{% else %} {% endif %}]</td>
-<td><a href="todo?id={{todo.id_}}">{{todo.title.newest|e}}</td>
+<td><a href="todo?id={{todo.id_}}">{{todo.title_then|e}}</td>
 <td>{{todo.comment|e}}</td>
 </tr>
 {% endfor %}
index 6954fd3a85974e44b1db0801968c9313d60fdaea..2e1a380502f2e10e934b7d4f5eab86254ebd8c8d 100644 (file)
@@ -47,11 +47,11 @@ td.todo_line {
 <td class="todo_line">{% if node.todo.effort %}{{ node.todo.effort }}{% endif %}</td>
 {% else %}
 <td class="todo_line"><input name="done" type="checkbox" value="{{node.todo.id_}}" {% if not node.todo.is_doable %}disabled{% endif %}/></td>
-<td class="todo_line"><input name="effort" type="number" step=0.1 size=5 placeholder={{node.todo.process.effort.newest }} value={{node.todo.effort}} /></td>
+<td class="todo_line"><input name="effort" type="number" step=0.1 size=5 placeholder={{node.todo.effort_then}} value={{node.todo.effort}} /></td>
 {% endif %}
 <td class="todo_line">
 {% for i in range(indent) %}&nbsp; {% endfor %} +
-{% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.process.title.newest|e}}</a>{% if node.seen %}){% endif %}
+{% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.title_then|e}}</a>{% if node.seen %}){% endif %}
 </td>
 <td class="todo_line">-&gt;</td>
 
@@ -86,7 +86,7 @@ td.todo_line {
 <tr>
 {% if path|length > 0 and not path[-1].todo.is_done %}
 <td>
-({% for path_node in path %}<a href="todo?id={{path_node.todo.id_}}">{{path_node.todo.process.title.newest|e}}</a>  &lt;- {% endfor %})
+({% for path_node in path %}<a href="todo?id={{path_node.todo.id_}}">{{path_node.todo.title_then|e}}</a>  &lt;- {% endfor %})
 </td>
 </tr>
 
@@ -97,7 +97,7 @@ td.todo_line {
 <td>
 {% for i in range(indent) %}&nbsp; {% endfor %} +
 {% endif %}
-{% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.process.title.newest|e}}</a> {% if node.todo.comment|length > 0 %}[{{node.todo.comment|e}}]{% endif %}{% if node.seen %}){% endif %}
+{% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.title_then|e}}</a> {% if node.todo.comment|length > 0 %}[{{node.todo.comment|e}}]{% endif %}{% if node.seen %}){% endif %}
 </td>
 </tr>
 
@@ -150,7 +150,7 @@ add todo: <input name="new_todo" list="processes" autocomplete="off" />
 {% endfor %}
 
 <td class="cond_line_{{loop.index0 % 3}}">[{% if condition.is_active %}X{% else %}&nbsp;{% endif %}]</td>
-<td colspan=4 class="cond_line_{{loop.index0 % 3}}"><a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a></td>
+<td colspan=4 class="cond_line_{{loop.index0 % 3}}"><a href="condition?id={{condition.id_}}">{{condition.title.at(day.date)|e}}</a></td>
 
 {% for _ in conditions_present %}
 {% if outer_loop.index0 + loop.index0 < conditions_present|length %}
index a711568edf75c6291051cb300325b650ed57cb2e..41d894bb0ef6b5f47a58e04323c4902b404f7d1a 100644 (file)
@@ -4,7 +4,7 @@
 
 
 {% block content %}
-<h3>Todo: {{todo.process.title.newest|e}}</h3>
+<h3>Todo: {{todo.title_then|e}}</h3>
 <form action="todo?id={{todo.id_}}" method="POST">
 <table>
 
@@ -25,7 +25,7 @@
 
 <tr>
 <th>effort</th>
-<td><input type="number" name="effort" step=0.1 size=5 placeholder={{todo.process.effort.newest }} value={{ todo.effort }} /><br /></td>
+<td><input type="number" name="effort" step=0.1 size=5 placeholder={{todo.effort_then}} value={{todo.effort}} /><br /></td>
 </tr>
 
 <tr>
 
 <tr>
 <th>conditions</th>
-<td>{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates", historical=true) }}</td>
 </tr>
 
 <tr>
 <th>blockers</th>
-<td>{{ macros.simple_checkbox_table("blocker", todo.blockers, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("blocker", todo.blockers, "condition", "condition_candidates", historical=true) }}</td>
 </tr>
 
 <tr>
 <th>enables</th>
-<td>{{ macros.simple_checkbox_table("enables", todo.enables, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("enables", todo.enables, "condition", "condition_candidates", historical=true) }}</td>
 </tr>
 
 <tr>
 <th>disables</th>
-<td>{{ macros.simple_checkbox_table("disables", todo.disables, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("disables", todo.disables, "condition", "condition_candidates", historical=true) }}</td>
 </tr>
 
 <tr>
 <th>parents</th>
 <td>
 {% for parent in todo.parents %}
-<a href="todo?id={{parent.id_}}">{{parent.process.title.newest|e}}</a><br />
+<a href="todo?id={{parent.id_}}">{{parent.title_then|e}}</a><br />
 {% endfor %}
 </td>
 </tr>
 
 <tr>
 <th>children</th>
-<td>{{ macros.simple_checkbox_table("adopt", todo.children, "adopt", "todo_candidates", "adopt") }}</td>
+<td>{{ macros.simple_checkbox_table("adopt", todo.children, "adopt", "todo_candidates", "adopt", true) }}</td>
 </tr>
 
 </table>
index 54ac6f568fa25b05d2f833ecc42be49f5a207423..6cbf0bc5872917852bc95095a0383075ae3dc548 100644 (file)
@@ -26,7 +26,7 @@ in comment  <input name="comment_pattern" value="{{comment_pattern}}" />
 <tr>
 <td>[{% if todo.is_done %}x{% else %} {% endif %}]</td>
 <td><a href="{{todo.date}}">{{todo.date}}</a></td>
-<td><a href="process?id={{todo.process.id_}}">{{todo.process.title.newest}}</a></td>
+<td><a href="process?id={{todo.process.id_}}">{{todo.title_then}}</a></td>
 <td><a href="{{todo.comment}}">{{todo.comment}}</a></td>
 </tr>
 {% endfor %}