X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomtask%2Fhttp.py;h=f5e24edecfc0c3bfb86700cc3a5d709db3f24c68;hb=77e9d9dfa5681bc32e8aec8558d0fa449805e3ac;hp=080af8ce1a127880368c8c4bedb3cf4e0aebaffc;hpb=e150bee233a648950061b716dc1780581105ede6;p=plomtask diff --git a/plomtask/http.py b/plomtask/http.py index 080af8c..f5e24ed 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -123,19 +123,24 @@ class TaskHandler(BaseHTTPRequestHandler): todays_todos = Todo.by_date(self.conn, date) conditions_present = [] enablers_for = {} + disablers_for = {} for todo in todays_todos: - for condition in todo.conditions: + for condition in todo.conditions + todo.blockers: if condition not in conditions_present: conditions_present += [condition] enablers_for[condition.id_] = [p for p in Process.all(self.conn) if condition in p.enables] + disablers_for[condition.id_] = [p for p in + Process.all(self.conn) + if condition in p.disables] seen_todos: set[int] = set() top_nodes = [t.get_step_tree(seen_todos) for t in todays_todos if not t.parents] return {'day': Day.by_id(self.conn, date, create=True), 'top_nodes': top_nodes, 'enablers_for': enablers_for, + 'disablers_for': disablers_for, 'conditions_present': conditions_present, 'processes': Process.all(self.conn)} @@ -149,7 +154,8 @@ class TaskHandler(BaseHTTPRequestHandler): def do_GET_conditions(self) -> dict[str, object]: """Show all Conditions.""" - conditions = Condition.all(self.conn) + pattern = self.params.get_str('pattern') + conditions = Condition.matching(self.conn, pattern) sort_by = self.params.get_str('sort_by') if sort_by == 'is_active': conditions.sort(key=lambda c: c.is_active) @@ -159,7 +165,9 @@ class TaskHandler(BaseHTTPRequestHandler): conditions.sort(key=lambda c: c.title.newest, reverse=True) else: conditions.sort(key=lambda c: c.title.newest) - return {'conditions': conditions, 'sort_by': sort_by} + return {'conditions': conditions, + 'sort_by': sort_by, + 'pattern': pattern} def do_GET_condition(self) -> dict[str, object]: """Show Condition of ?id=.""" @@ -208,7 +216,8 @@ class TaskHandler(BaseHTTPRequestHandler): def do_GET_processes(self) -> dict[str, object]: """Show all Processes.""" - processes = Process.all(self.conn) + pattern = self.params.get_str('pattern') + processes = Process.matching(self.conn, pattern) sort_by = self.params.get_str('sort_by') if sort_by == 'steps': processes.sort(key=lambda c: len(c.explicit_steps)) @@ -218,7 +227,7 @@ class TaskHandler(BaseHTTPRequestHandler): processes.sort(key=lambda c: c.title.newest, reverse=True) else: processes.sort(key=lambda c: c.title.newest) - return {'processes': processes, 'sort_by': sort_by} + return {'processes': processes, 'sort_by': sort_by, 'pattern': pattern} def do_POST(self) -> None: """Handle any POST request.""" @@ -301,6 +310,7 @@ class TaskHandler(BaseHTTPRequestHandler): effort = self.form_data.get_str('effort', ignore_strict=True) todo.effort = float(effort) if effort else None todo.set_conditions(self.conn, self.form_data.get_all_int('condition')) + todo.set_blockers(self.conn, self.form_data.get_all_int('blocker')) todo.set_enables(self.conn, self.form_data.get_all_int('enables')) todo.set_disables(self.conn, self.form_data.get_all_int('disables')) todo.is_done = len(self.form_data.get_all_str('done')) > 0 @@ -326,12 +336,15 @@ class TaskHandler(BaseHTTPRequestHandler): process.effort.set(self.form_data.get_float('effort')) process.set_conditions(self.conn, self.form_data.get_all_int('condition')) + process.set_blockers(self.conn, self.form_data.get_all_int('blocker')) process.set_enables(self.conn, self.form_data.get_all_int('enables')) process.set_disables(self.conn, self.form_data.get_all_int('disables')) process.calendarize = self.form_data.get_all_str('calendarize') != [] process.save(self.conn) - process.explicit_steps = [] steps: list[tuple[int | None, int, int | None]] = [] + for step_id in self.form_data.get_all_int('keep_step'): + if step_id not in self.form_data.get_all_int('steps'): + raise BadFormatException('trying to keep unknown step') for step_id in self.form_data.get_all_int('steps'): for step_process_id in self.form_data.get_all_int( f'new_step_to_{step_id}'):