From: Christian Heller Date: Sat, 10 Aug 2024 01:12:21 +0000 (+0200) Subject: Minor improvements of TaskHandler code. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/process_titles?a=commitdiff_plain;h=46e509c1467535e2281922718dc60ee89a0a019e;p=plomtask Minor improvements of TaskHandler code. --- diff --git a/plomtask/http.py b/plomtask/http.py index 704ae06..cba55d6 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -452,7 +452,6 @@ class TaskHandler(BaseHTTPRequestHandler): process_id = self._params.get_int_or_none('process_id') comment_pattern = self._params.get_str_or_fail('comment_pattern', '') # - todos = [] ret = Todo.by_date_range_with_limits(self._conn, (start, end)) todos_by_date_range, start, end = ret todos = [t for t in todos_by_date_range @@ -500,14 +499,16 @@ class TaskHandler(BaseHTTPRequestHandler): 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') - # + title_new = None if title_64: try: - title = b64decode(title_64.encode()).decode() + title_new = b64decode(title_64.encode()).decode() except binascii_Exception as exc: msg = 'invalid base64 for ?title_b64=' raise BadFormatException(msg) from exc - process.title.set(title) + # + if title_new: + process.title.set(title_new) preset_top_step = None owners = process.used_as_step_by(self._conn) for step_id in owner_ids: @@ -598,15 +599,15 @@ class TaskHandler(BaseHTTPRequestHandler): comments = self._form.get_all_str('comment') efforts = self._form.get_all_floats_or_nones('effort') done_todos = self._form.get_all_int('done') - # - for _ in [id_ for id_ in done_todos if id_ not in old_todos]: - raise BadFormatException('"done" field refers to unknown Todo') is_done = [t_id in done_todos for t_id in old_todos] if not (len(old_todos) == len(is_done) == len(comments) == len(efforts)): msg = 'not equal number each of number of todo_id, comments, ' +\ 'and efforts inputs' raise BadFormatException(msg) + for _ in [id_ for id_ in done_todos if id_ not in old_todos]: + raise BadFormatException('"done" field refers to unknown Todo') + # day = Day.by_id_or_create(self._conn, date) day.comment = day_comment day.save(self._conn) @@ -674,10 +675,10 @@ class TaskHandler(BaseHTTPRequestHandler): # todo.set_condition_relations(self._conn, *cond_rels) for child in [c for c in todo.children if c.id_ not in adoptees]: - todo.remove_child(child) + todo.remove_child(child) for child_id in [id_ for id_ in adoptees if id_ not in [c.id_ for c in todo.children]]: - todo.add_child(Todo.by_id(self._conn, child_id)) + todo.add_child(Todo.by_id(self._conn, child_id)) todo.update_attrs(**to_update) for approach, proc_ids in to_make.items(): for process_id in proc_ids: