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':
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}
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:
"""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
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
-{% 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>
<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 %}
{% 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 %}
<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) %} {% 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">-></td>
<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> <- {% endfor %})
+({% for path_node in path %}<a href="todo?id={{path_node.todo.id_}}">{{path_node.todo.title_then|e}}</a> <- {% endfor %})
</td>
</tr>
<td>
{% for i in range(indent) %} {% 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>
{% endfor %}
<td class="cond_line_{{loop.index0 % 3}}">[{% if condition.is_active %}X{% else %} {% 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 %}
{% 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>
<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>
<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 %}