- date = params.get_str('date', todays_date())
- day = Day.by_date(conn, date, create=True)
- todos = Todo.by_date(conn, date)
- conditions_listing = []
- for condition in Condition.all(conn):
- enablers = Todo.enablers_for_at(conn, condition, date)
- disablers = Todo.disablers_for_at(conn, condition, date)
- conditions_listing += [{
- 'condition': condition,
- 'enablers': enablers,
- 'disablers': disablers}]
- return self.server.jinja.get_template('day.html').render(
- day=day, processes=Process.all(conn), todos=todos,
- conditions_listing=conditions_listing)
-
- def do_GET_todo(self, conn: DatabaseConnection, params:
- ParamsParser) -> str:
+
+ class ConditionListing(NamedTuple):
+ """Listing of Condition augmented with its enablers, disablers."""
+ condition: Condition
+ enablers: list[Todo]
+ disablers: list[Todo]
+
+ date = self.params.get_str('date', todays_date())
+ top_todos = [t for t in Todo.by_date(self.conn, date) if not t.parents]
+ todo_trees = [t.get_undone_steps_tree() for t in top_todos]
+ done_trees = []
+ for t in top_todos:
+ done_trees += t.get_done_steps_tree()
+ condition_listings: list[ConditionListing] = []
+ for cond in Condition.all(self.conn):
+ enablers = Todo.enablers_for_at(self.conn, cond, date)
+ disablers = Todo.disablers_for_at(self.conn, cond, date)
+ condition_listings += [ConditionListing(cond, enablers, disablers)]
+ return {'day': Day.by_id(self.conn, date, create=True),
+ 'todo_trees': todo_trees,
+ 'done_trees': done_trees,
+ 'processes': Process.all(self.conn),
+ 'condition_listings': condition_listings}
+
+ def do_GET_todo(self) -> dict[str, object]: