From 53f151ef577dd8115e72d38a8991ad77c75f7e59 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 18 May 2024 05:01:16 +0200 Subject: [PATCH] Add VersionedAttributes history pages for Conditions. --- plomtask/http.py | 16 +++++++++++++++- templates/condition.html | 4 ++-- templates/condition_descriptions.html | 8 ++++++++ templates/condition_titles.html | 8 ++++++++ templates/process_efforts.html | 1 - 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 templates/condition_descriptions.html create mode 100644 templates/condition_titles.html diff --git a/plomtask/http.py b/plomtask/http.py index 2c7e628..88725fc 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -96,7 +96,9 @@ class TaskHandler(BaseHTTPRequestHandler): self._init_handling() if self.site in {'calendar', 'day', 'process', 'process_titles', 'process_descriptions', 'process_efforts', - 'processes', 'todo', 'condition', 'conditions'}: + 'processes', 'todo', 'condition', + 'condition_titles', 'condition_descriptions', + 'conditions'}: template = f'{self.site}.html' ctx = getattr(self, f'do_GET_{self.site}')() html = self.server.jinja.get_template(template).render(**ctx) @@ -156,6 +158,18 @@ class TaskHandler(BaseHTTPRequestHandler): id_ = self.params.get_int_or_none('id') return {'condition': Condition.by_id(self.conn, id_, create=True)} + def do_GET_condition_titles(self) -> dict[str, object]: + """Show title history of Condition of ?id=.""" + id_ = self.params.get_int_or_none('id') + condition = Condition.by_id(self.conn, id_) + return {'condition': condition} + + def do_GET_condition_descriptions(self) -> dict[str, object]: + """Show description historys of Condition of ?id=.""" + id_ = self.params.get_int_or_none('id') + condition = Condition.by_id(self.conn, id_) + return {'condition': condition} + def do_GET_process(self) -> dict[str, object]: """Show Process of ?id=.""" id_ = self.params.get_int_or_none('id') diff --git a/templates/condition.html b/templates/condition.html index 8e73e5e..1fc5902 100644 --- a/templates/condition.html +++ b/templates/condition.html @@ -10,7 +10,7 @@ title - +{% if condition.id_ %} [history]{% endif %} @@ -20,7 +20,7 @@ description - +{% if condition.id_ %} [history]{% endif %} diff --git a/templates/condition_descriptions.html b/templates/condition_descriptions.html new file mode 100644 index 0000000..17dd066 --- /dev/null +++ b/templates/condition_descriptions.html @@ -0,0 +1,8 @@ +{% extends '_base.html' %} +{% import '_macros.html' as macros %} + + + +{% block content %} +{{ macros.history_page("condition", condition, "description", condition.description, true) }} +{% endblock %} diff --git a/templates/condition_titles.html b/templates/condition_titles.html new file mode 100644 index 0000000..6ab8ca9 --- /dev/null +++ b/templates/condition_titles.html @@ -0,0 +1,8 @@ +{% extends '_base.html' %} +{% import '_macros.html' as macros %} + + + +{% block content %} +{{ macros.history_page("condition", condition, "title", condition.title) }} +{% endblock %} diff --git a/templates/process_efforts.html b/templates/process_efforts.html index bdfa7dd..579ded1 100644 --- a/templates/process_efforts.html +++ b/templates/process_efforts.html @@ -6,4 +6,3 @@ {% block content %} {{ macros.history_page("process", process, "effort", process.effort) }} {% endblock %} - -- 2.30.2