From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 6 Jun 2024 03:15:12 +0000 (+0200)
Subject: When opening new Process from ProcessStep add field, pre-set as owned by previous... 
X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/%7Broute%7D?a=commitdiff_plain;h=e3b01fe14d7a3b824b909382671acc4657e98145;p=plomtask

When opening new Process from ProcessStep add field, pre-set as owned by previous Process.
---

diff --git a/plomtask/http.py b/plomtask/http.py
index 9bb96f9..9680778 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -240,9 +240,12 @@ class TaskHandler(BaseHTTPRequestHandler):
         if title_64:
             title = b64decode(title_64.encode()).decode()
             process.title.set(title)
+        owners = process.used_as_step_by(self.conn)
+        for step_id in self.params.get_all_int('step_to'):
+            owners += [Process.by_id(self.conn, step_id)]
         return {'process': process, 'is_new': process.id_ is None,
                 'steps': process.get_steps(self.conn),
-                'owners': process.used_as_step_by(self.conn),
+                'owners': owners,
                 'n_todos': len(Todo.by_process_id(self.conn, process.id_)),
                 'process_candidates': Process.all(self.conn),
                 'condition_candidates': Condition.all(self.conn)}
@@ -418,7 +421,8 @@ class TaskHandler(BaseHTTPRequestHandler):
         process.set_owners(self.conn, self.form_data.get_all_int('step_of'))
         if new_process_title:
             title_b64_encoded = b64encode(new_process_title.encode()).decode()
-            return f'/process?title_b64={title_b64_encoded}'
+            params = f'step_to={process.id_}&title_b64={title_b64_encoded}'
+            return f'/process?{params}'
         return f'/process?id={process.id_}'
 
     def do_POST_condition(self) -> str: