From 501b2ef5f6373807b7728e7b8539105aa9030809 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 21 Jun 2024 23:46:25 +0200 Subject: [PATCH] Minor reorganization of GET handlers code. --- plomtask/http.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plomtask/http.py b/plomtask/http.py index 2706603..0f5e88e 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -424,8 +424,8 @@ class TaskHandler(BaseHTTPRequestHandler): def do_GET_conditions(self) -> dict[str, object]: """Show all Conditions.""" pattern = self._params.get_str('pattern') - conditions = Condition.matching(self.conn, pattern) sort_by = self._params.get_str('sort_by') + conditions = Condition.matching(self.conn, pattern) if sort_by == 'is_active': conditions.sort(key=lambda c: c.is_active) elif sort_by == '-is_active': @@ -462,15 +462,17 @@ class TaskHandler(BaseHTTPRequestHandler): @_get_item(Process) def do_GET_process(self, process: Process) -> dict[str, object]: """Show Process of ?id=.""" + owner_ids = self._params.get_all_int('step_to') + owned_ids = self._params.get_all_int('has_step') title_64 = self._params.get_str('title_b64') 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'): + for step_id in owner_ids: owners += [Process.by_id(self.conn, step_id)] preset_top_step = None - for process_id in self._params.get_all_int('has_step'): + for process_id in owned_ids: preset_top_step = process_id return {'process': process, 'is_new': process.id_ is None, 'preset_top_step': preset_top_step, @@ -497,8 +499,8 @@ class TaskHandler(BaseHTTPRequestHandler): def do_GET_processes(self) -> dict[str, object]: """Show all Processes.""" pattern = self._params.get_str('pattern') - processes = Process.matching(self.conn, pattern) sort_by = self._params.get_str('sort_by') + processes = Process.matching(self.conn, pattern) if sort_by == 'steps': processes.sort(key=lambda p: len(p.explicit_steps)) elif sort_by == '-steps': -- 2.30.2