From: Christian Heller <c.heller@plomlompom.de> Date: Thu, 30 May 2024 04:55:31 +0000 (+0200) Subject: To Condition view, add listings of related Processes. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/tasks?a=commitdiff_plain;h=63073c2c05785d2b5539780dd5bc40adff57aab1;p=plomtask To Condition view, add listings of related Processes. --- diff --git a/plomtask/http.py b/plomtask/http.py index 8255aa2..b81083b 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -207,7 +207,13 @@ class TaskHandler(BaseHTTPRequestHandler): def do_GET_condition(self) -> dict[str, object]: """Show Condition of ?id=.""" id_ = self.params.get_int_or_none('id') - return {'condition': Condition.by_id(self.conn, id_, create=True)} + c = Condition.by_id(self.conn, id_, create=True) + ps = Process.all(self.conn) + return {'condition': c, + 'enabled_processes': [p for p in ps if c in p.conditions], + 'disabled_processes': [p for p in ps if c in p.blockers], + 'enabling_processes': [p for p in ps if c in p.enables], + 'disabling_processes': [p for p in ps if c in p.disables]} def do_GET_condition_titles(self) -> dict[str, object]: """Show title history of Condition of ?id=.""" diff --git a/templates/condition.html b/templates/condition.html index 1fc5902..324c8f8 100644 --- a/templates/condition.html +++ b/templates/condition.html @@ -23,6 +23,42 @@ <td><textarea name="description">{{condition.description.newest|e}}</textarea>{% if condition.id_ %} [<a href="condition_descriptions?id={{condition.id_}}">history</a>]{% endif %}</td> <tr/> +<tr> +<th>enables</th> +<td> +{% for process in enabled_processes %} +<a href="process?id=process.id_">{{process.title.newest|e}}</a><br /> +{% endfor %} +</td> +</tr> + +<tr> +<th>disables</th> +<td> +{% for process in disabled_processes %} +<a href="process?id=process.id_">{{process.title.newest|e}}</a><br /> +{% endfor %} +</td> +</tr> + +<tr> +<th>enabled by</th> +<td> +{% for process in enabling_processes %} +<a href="process?id=process.id_">{{process.title.newest|e}}</a><br /> +{% endfor %} +</td> +</tr> + +<tr> +<th>disabled by</th> +<td> +{% for process in disabling_processes %} +<a href="process?id=process.id_">{{process.title.newest|e}}</a><br /> +{% endfor %} +</td> +</tr> + </table> {{ macros.edit_buttons() }} {% endblock %}