From b7cd01785f7fbf1f489e297f2aea2e8477e0d05a Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 23 Dec 2024 22:08:30 +0100
Subject: [PATCH] Fix broken ProcessStep suppression.

---
 plomtask/http.py       | 2 +-
 plomtask/processes.py  | 6 +++++-
 templates/process.html | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/plomtask/http.py b/plomtask/http.py
index 99d3850..e86d314 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -748,7 +748,7 @@ class TaskHandler(BaseHTTPRequestHandler):
                      in ['conditions', 'blockers', 'enables', 'disables']]
         calendarize = self._form.get_bool('calendarize')
         step_of = self._form.get_all_str('step_of')
-        suppressions = self._form.get_all_int('suppresses')
+        suppressions = self._form.get_all_int('suppressed_steps')
         kept_steps = self._form.get_all_int('kept_steps')
         new_top_step_procs = self._form.get_all_str('new_top_step')
         new_steps_to = {}
diff --git a/plomtask/processes.py b/plomtask/processes.py
index 23eb624..d2e8410 100644
--- a/plomtask/processes.py
+++ b/plomtask/processes.py
@@ -69,7 +69,11 @@ class Process(BaseModel[int], ConditionsRelations):
                 target = getattr(process, name)
                 target += [Condition.by_id(db_conn, c_id)]
         for row_ in db_conn.row_where('process_steps', 'owner', process.id_):
-            step = ProcessStep.from_table_row(db_conn, row_)
+            # NB: It's tempting to ProcessStep.from_table_row(row_) directly,
+            # but we don't want to unnecessarily invalidate cached ProcessSteps
+            # elsewhere (notably, other Processes .suppressed_steps), as a
+            # complete reload like this would do
+            step = ProcessStep.by_id(db_conn, row_[0])
             process.explicit_steps += [step]
         for row_ in db_conn.row_where('process_step_suppressions', 'process',
                                       process.id_):
diff --git a/templates/process.html b/templates/process.html
index a4029dc..cf0bb6e 100644
--- a/templates/process.html
+++ b/templates/process.html
@@ -53,7 +53,7 @@ details[open] > summary::after {
 </td>
 {% if (not step_node.is_explicit) and (not step_node.seen) %}
 <td>
-<input type="checkbox" name="suppresses" value="{{step_id}}" {% if step_node.is_suppressed %}checked{% endif %}> suppress
+<input type="checkbox" name="suppressed_steps" value="{{step_id}}" {% if step_node.is_suppressed %}checked{% endif %}> suppress
 </td>
 {% endif %}
 </tr>
-- 
2.30.2