From: Christian Heller <c.heller@plomlompom.de>
Date: Sat, 18 May 2024 02:47:49 +0000 (+0200)
Subject: Add VersionedAttribute history display pages for Processes.
X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/static/blog?a=commitdiff_plain;h=29969c2d0fb6c464662737df1da94f76dc2c0982;p=taskplom
Add VersionedAttribute history display pages for Processes.
---
diff --git a/plomtask/http.py b/plomtask/http.py
index 98bb49f..2c7e628 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -94,8 +94,9 @@ class TaskHandler(BaseHTTPRequestHandler):
"""Handle any GET request."""
try:
self._init_handling()
- if self.site in {'calendar', 'day', 'process', 'processes', 'todo',
- 'condition', 'conditions'}:
+ if self.site in {'calendar', 'day', 'process', 'process_titles',
+ 'process_descriptions', 'process_efforts',
+ 'processes', 'todo', 'condition', 'conditions'}:
template = f'{self.site}.html'
ctx = getattr(self, f'do_GET_{self.site}')()
html = self.server.jinja.get_template(template).render(**ctx)
@@ -156,7 +157,7 @@ class TaskHandler(BaseHTTPRequestHandler):
return {'condition': Condition.by_id(self.conn, id_, create=True)}
def do_GET_process(self) -> dict[str, object]:
- """Show process of ?id=."""
+ """Show Process of ?id=."""
id_ = self.params.get_int_or_none('id')
process = Process.by_id(self.conn, id_, create=True)
return {'process': process,
@@ -165,6 +166,24 @@ class TaskHandler(BaseHTTPRequestHandler):
'step_candidates': Process.all(self.conn),
'condition_candidates': Condition.all(self.conn)}
+ def do_GET_process_titles(self) -> dict[str, object]:
+ """Show title history of Process of ?id=."""
+ id_ = self.params.get_int_or_none('id')
+ process = Process.by_id(self.conn, id_)
+ return {'process': process}
+
+ def do_GET_process_descriptions(self) -> dict[str, object]:
+ """Show description historys of Process of ?id=."""
+ id_ = self.params.get_int_or_none('id')
+ process = Process.by_id(self.conn, id_)
+ return {'process': process}
+
+ def do_GET_process_efforts(self) -> dict[str, object]:
+ """Show default effort history of Process of ?id=."""
+ id_ = self.params.get_int_or_none('id')
+ process = Process.by_id(self.conn, id_)
+ return {'process': process}
+
def do_GET_processes(self) -> dict[str, object]:
"""Show all Processes."""
return {'processes': Process.all(self.conn)}
diff --git a/templates/process.html b/templates/process.html
index 5aebe53..d833c52 100644
--- a/templates/process.html
+++ b/templates/process.html
@@ -42,17 +42,17 @@ add: <input name="new_step_to_{{step_id}}" list="candidates" autocomplete="off"
<tr>
<th>title</th>
-<td><input name="title" value="{{process.title.newest|e}}" /></td>
+<td><input name="title" value="{{process.title.newest|e}}" />{% if process.id_ %} [<a href="process_titles?id={{process.id_}}">history</a>]{% endif %}</td>
</tr>
<tr>
<th>default effort</th>
-<td><input name="effort" type="number" step=0.1 value={{process.effort.newest}} /></td>
+<td><input name="effort" type="number" step=0.1 value={{process.effort.newest}} />{% if process.id_ %} [<a href="process_efforts?id={{process.id_}}">history</a>]{% endif %}</td>
</tr>
<tr>
<th>description</th>
-<td><textarea name="description">{{process.description.newest|e}}</textarea></td>
+<td><textarea name="description">{{process.description.newest|e}}</textarea><br />{% if process.id_ %} [<a href="process_descriptions?id={{process.id_}}">history</a>]{% endif %}</td>
</tr>
<tr>
diff --git a/templates/process_descriptions.html b/templates/process_descriptions.html
new file mode 100644
index 0000000..f1b93cb
--- /dev/null
+++ b/templates/process_descriptions.html
@@ -0,0 +1,23 @@
+{% extends '_base.html' %}
+
+
+
+{% block content %}
+<h3>process description history</h3>
+<table>
+
+<tr>
+<th>process</th>
+<td><a href="process?id={{process.id_}}">{{process.title.newest|e}}</a></td>
+</tr>
+
+{% for date in process.description.history.keys() | sort(reverse=True) %}
+<tr>
+<th>{{date | truncate(19, True, '') }}</th>
+<td><pre>{{process.description.history[date]}}</pre></td>
+</tr>
+{% endfor %}
+
+</table>
+{% endblock %}
+
diff --git a/templates/process_efforts.html b/templates/process_efforts.html
new file mode 100644
index 0000000..31efcc3
--- /dev/null
+++ b/templates/process_efforts.html
@@ -0,0 +1,23 @@
+{% extends '_base.html' %}
+
+
+
+{% block content %}
+<h3>process default effort history</h3>
+<table>
+
+<tr>
+<th>process</th>
+<td><a href="process?id={{process.id_}}">{{process.title.newest|e}}</a></td>
+</tr>
+
+{% for date in process.effort.history.keys() | sort(reverse=True) %}
+<tr>
+<th>{{date | truncate(19, True, '') }}</th>
+<td>{{process.effort.history[date]}}</td>
+</tr>
+{% endfor %}
+
+</table>
+{% endblock %}
+
diff --git a/templates/process_titles.html b/templates/process_titles.html
new file mode 100644
index 0000000..574ef1c
--- /dev/null
+++ b/templates/process_titles.html
@@ -0,0 +1,22 @@
+{% extends '_base.html' %}
+
+
+
+{% block content %}
+<h3>process title history</h3>
+<table>
+
+<tr>
+<th>process</th>
+<td><a href="process?id={{process.id_}}">{{process.title.newest|e}}</a></td>
+</tr>
+
+{% for date in process.title.history.keys() | sort(reverse=True) %}
+<tr>
+<th>{{date | truncate(19, True, '') }}</th>
+<td>{{process.title.history[date]}}</td>
+</tr>
+{% endfor %}
+
+</table>
+{% endblock %}