From: Christian Heller Date: Fri, 21 Jun 2024 21:46:25 +0000 (+0200) Subject: Minor reorganization of GET handlers code. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/do_tasks?a=commitdiff_plain;h=501b2ef5f6373807b7728e7b8539105aa9030809;p=plomtask Minor reorganization of GET handlers code. --- 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':