From: Christian Heller Date: Thu, 30 May 2024 04:12:35 +0000 (+0200) Subject: Display historical VersionedAttributes where it makes sense. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Bdb.prefix%7D%7D/todo?a=commitdiff_plain;h=5383b5cf1520a1cb66b4966dd4ee449a99f5e465;p=plomtask Display historical VersionedAttributes where it makes sense. --- diff --git a/plomtask/http.py b/plomtask/http.py index f6b17a0..8255aa2 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -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: diff --git a/plomtask/todos.py b/plomtask/todos.py index 712609a..ffef677 100644 --- a/plomtask/todos.py +++ b/plomtask/todos.py @@ -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 diff --git a/plomtask/versioned_attributes.py b/plomtask/versioned_attributes.py index 1810a31..b3442d7 100644 --- a/plomtask/versioned_attributes.py +++ b/plomtask/versioned_attributes.py @@ -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 diff --git a/templates/_macros.html b/templates/_macros.html index 25d94c5..b1f0104 100644 --- a/templates/_macros.html +++ b/templates/_macros.html @@ -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) %} {% for item in items %} @@ -25,7 +25,7 @@ {% endfor %} diff --git a/templates/calendar.html b/templates/calendar.html index 7724203..4d67242 100644 --- a/templates/calendar.html +++ b/templates/calendar.html @@ -52,7 +52,7 @@ to {% for todo in day.calendarized_todos %} - + {% endfor %} diff --git a/templates/day.html b/templates/day.html index 6954fd3..2e1a380 100644 --- a/templates/day.html +++ b/templates/day.html @@ -47,11 +47,11 @@ td.todo_line { {% else %} - + {% endif %} @@ -86,7 +86,7 @@ td.todo_line { {% if path|length > 0 and not path[-1].todo.is_done %} @@ -97,7 +97,7 @@ td.todo_line { @@ -150,7 +150,7 @@ add todo: {% endfor %} - + {% for _ in conditions_present %} {% if outer_loop.index0 + loop.index0 < conditions_present|length %} diff --git a/templates/todo.html b/templates/todo.html index a711568..41d894b 100644 --- a/templates/todo.html +++ b/templates/todo.html @@ -4,7 +4,7 @@ {% block content %} -

Todo: {{todo.process.title.newest|e}}

+

Todo: {{todo.title_then|e}}

-{{item.title.newest|e}} +{% if historical %}{{item.title_then}}{% else %}{{item.title.newest|e}}{% endif %}
[{% if todo.is_done %}X{% else %} {% endif %}]{{todo.title.newest|e}}{{todo.title_then|e}} {{todo.comment|e}}
{% if node.todo.effort %}{{ node.todo.effort }}{% endif %} {% for i in range(indent) %}  {% endfor %} + -{% if node.seen %}({% endif %}{{node.todo.process.title.newest|e}}{% if node.seen %}){% endif %} +{% if node.seen %}({% endif %}{{node.todo.title_then|e}}{% if node.seen %}){% endif %} ->
-({% for path_node in path %}{{path_node.todo.process.title.newest|e}} <- {% endfor %}) +({% for path_node in path %}{{path_node.todo.title_then|e}} <- {% endfor %})
{% for i in range(indent) %}  {% endfor %} + {% 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 %} +{% if node.seen %}({% endif %}{{node.todo.title_then|e}} {% if node.todo.comment|length > 0 %}[{{node.todo.comment|e}}]{% endif %}{% if node.seen %}){% endif %}
[{% if condition.is_active %}X{% else %} {% endif %}]{{condition.title.newest|e}}{{condition.title.at(day.date)|e}}
@@ -25,7 +25,7 @@ - + @@ -40,36 +40,36 @@ - + - + - + - + - +
effort

conditions{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates") }}{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates", historical=true) }}
blockers{{ macros.simple_checkbox_table("blocker", todo.blockers, "condition", "condition_candidates") }}{{ macros.simple_checkbox_table("blocker", todo.blockers, "condition", "condition_candidates", historical=true) }}
enables{{ macros.simple_checkbox_table("enables", todo.enables, "condition", "condition_candidates") }}{{ macros.simple_checkbox_table("enables", todo.enables, "condition", "condition_candidates", historical=true) }}
disables{{ macros.simple_checkbox_table("disables", todo.disables, "condition", "condition_candidates") }}{{ macros.simple_checkbox_table("disables", todo.disables, "condition", "condition_candidates", historical=true) }}
parents {% for parent in todo.parents %} -{{parent.process.title.newest|e}}
+{{parent.title_then|e}}
{% endfor %}
children{{ macros.simple_checkbox_table("adopt", todo.children, "adopt", "todo_candidates", "adopt") }}{{ macros.simple_checkbox_table("adopt", todo.children, "adopt", "todo_candidates", "adopt", true) }}
diff --git a/templates/todos.html b/templates/todos.html index 54ac6f5..6cbf0bc 100644 --- a/templates/todos.html +++ b/templates/todos.html @@ -26,7 +26,7 @@ in comment [{% if todo.is_done %}x{% else %} {% endif %}] {{todo.date}} -{{todo.process.title.newest}} +{{todo.title_then}} {{todo.comment}} {% endfor %}