From: Christian Heller Date: Fri, 23 Feb 2024 04:13:04 +0000 (+0100) Subject: Improve accounting scripts. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/static/tasks?a=commitdiff_plain;h=2ad9f7785539c0cd9f119d1f22b8057fab348114;p=misc Improve accounting scripts. --- diff --git a/ledger.py b/ledger.py index 958852a..d8b504a 100755 --- a/ledger.py +++ b/ledger.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta from urllib.parse import parse_qs, urlparse from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader from plomlib import PlomDB, PlomException, run_server, PlomHandler +from os.path import split as path_split db_path = '/home/plom/org/ledger2024.dat' server_port = 8082 @@ -468,6 +469,7 @@ class LedgerDB(PlomDB): date_today = str(datetime.now())[:10] if copy: content.date = date_today + index = -1 elif -1 == index and (content is None or [] == content): content = Booking(date=date_today, validate=False) if 'textarea' == edit_mode and content: @@ -476,7 +478,13 @@ class LedgerDB(PlomDB): for booking in self.bookings: for transfer_line in booking.transfer_lines: accounts.add(transfer_line.account) - return j2env.get_template('edit.html').render(content=content, index=index, error_msg=error_msg, edit_mode=edit_mode, accounts=accounts, adding=(copy or -1 == index)) + return j2env.get_template('edit.html').render( + content=content, + index=index, + error_msg=error_msg, + edit_mode=edit_mode, + accounts=accounts, + adding=-1 == index) def move_up(self, index): return self.move(index, -1) @@ -519,14 +527,15 @@ class LedgerHandler(PlomHandler): db = LedgerDB(prefix, ignore_editable_exceptions=True) index = 0 parsed_url = urlparse(self.path) + site = path_split(parsed_url.path)[1] for string in {'update', 'add', 'check', 'mirror', 'fill_sink', 'textarea', 'table', 'move_up', 'move_down', 'add_taxes', 'replace'}: if string in postvars.keys(): submit_button = string break - if f'{prefix}/ledger' == parsed_url.path and submit_button in {'move_up', 'move_down'}: + if 'ledger' == site and submit_button in {'move_up', 'move_down'}: mover = getattr(db, submit_button) index = mover(int(postvars[submit_button][0])) - elif prefix + '/edit' == parsed_url.path: + elif 'edit' == site: index = int(postvars['index'][0]) edit_mode = postvars['edit_mode'][0] validate = submit_button in {'update', 'add', 'copy', 'check'} @@ -542,7 +551,6 @@ class LedgerHandler(PlomHandler): booking = Booking.from_postvars(postvars, starts_at, validate) if submit_button in {'update', 'add'}: if submit_button == 'update': - # if 'textarea' == edit_mode and 'delete' == ''.join([l.text_line for l in lines]).strip(): if 'textarea' == edit_mode and delete: del db.bookings[index] # if not creating new Booking, and date unchanged, keep it in place @@ -571,7 +579,7 @@ class LedgerHandler(PlomHandler): return db.write_db() index = index if index >= 0 else len(db.bookings) - 1 - self.redirect(prefix + f'/ledger#{index}') + self.redirect('ledger#{index}') def do_GET(self): self.try_do(self.forward_gets) @@ -588,11 +596,12 @@ class LedgerHandler(PlomHandler): self.send_HTML(page) return parsed_url = urlparse(self.path) + site = path_split(parsed_url.path)[1] params = parse_qs(parsed_url.query) - if parsed_url.path == f'{prefix}/balance': + if site == 'balance': stop = params.get('until_after', [None])[0] page = db.balance_as_html(stop) - elif parsed_url.path == f'{prefix}/edit': + elif site == 'edit': index = params.get('i', [-1])[0] copy = params.get('copy', [0])[0] page = db.edit(int(index), copy=bool(copy)) diff --git a/todo.py b/todo.py index 6c84ee0..c3551a4 100644 --- a/todo.py +++ b/todo.py @@ -21,25 +21,22 @@ def today_date(with_time=False): class AttributeWithHistory: - def __init__(self, default_if_empty, history=None, then_date='2000-01-01', set_check=None, alt_get=None): + def __init__(self, default_if_empty, history=None, then_date='2000-01-01', set_check=None): self.default = default_if_empty self.then_date = then_date self.history = history if history else {} self.set_check = set_check - self.alt_get = alt_get def set(self, value): + print("DEBUG set", value, "HAS SET CHECK?", self.set_check) if self.set_check: + print("DEBUG set CALLED SET CHECK") self.set_check(value) keys = sorted(self.history.keys()) if len(self.history) == 0 or value != self.history[keys[-1]]: self.history[today_date(with_time=True)] = value def at(self, queried_date): - if self.alt_get: - ret = self.alt_get('at', queried_date) - if ret is not None: - return ret if 0 == len(self.history): return self.default ret = self.history[sorted(self.history.keys())[0]] @@ -51,24 +48,52 @@ class AttributeWithHistory: @property def now(self): - if self.alt_get: - ret = self.alt_get('now') - if ret is not None: - return ret keys = sorted(self.history.keys()) return self.default if 0 == len(self.history) else self.history[keys[-1]] @property def then(self): - if self.alt_get: - ret = self.alt_get('then') - if ret is not None: - return ret return self.at(self.then_date) -class Task: +class TaskLike: + + def __init__(self, db, id_, comment): + self.db = db + self.id_ = id_ + self.comment = comment + self.dependers = [] + + @property + def visible(self): + visible_by_and = 0 == len([tag for tag in self.db.tag_filter_and + if not tag in self.tags]) + visible_by_not = 0 == len([tag for tag in self.db.tag_filter_not + if tag in self.tags]) + return visible_by_and and visible_by_not + + @property + def deps_depth(self): + if len(self.deps) == 0: + return 0 + return 1 + max([d.deps_depth for d in self.deps]) + + @property + def deps_chain(self): + all_deps = set() + def add_deps(todo, all_deps): + for dep in todo.deps: + all_deps.add(dep) + add_deps(dep, all_deps) + add_deps(self, all_deps) + chain = list(all_deps) + chain.sort(key=lambda t: t.deps_depth) + return chain + + + +class Task(TaskLike): def __init__(self, db, @@ -76,18 +101,13 @@ class Task: title_history=None, tags_history=None, default_effort_history=None, - subtask_ids_history=None, + dep_ids_history=None, comment=''): - self.db = db - self.id_ = id_ + super().__init__(db, id_, comment) self.title = AttributeWithHistory('', title_history, self.db.selected_date) self.tags = AttributeWithHistory(set(), tags_history, self.db.selected_date) - self.default_effort = AttributeWithHistory(0.0, default_effort_history, self.db.selected_date, alt_get=self.subtasks_sum_maker()) - self.subtask_ids = AttributeWithHistory(set(), subtask_ids_history, self.db.selected_date, set_check=self.subtask_loop_checker()) - self.comment = comment - - self.visible = True - self.dependers = [] + self.default_effort = AttributeWithHistory(0.0, default_effort_history, self.db.selected_date) + self.dep_ids = AttributeWithHistory(set(), dep_ids_history, self.db.selected_date, set_check=self.dep_loop_checker()) @classmethod def from_dict(cls, db, d, id_): @@ -97,7 +117,7 @@ class Task: d['title_history'], {k: set(v) for k, v in d['tags_history'].items()}, d['default_effort_history'], - {k: set(v) for k, v in d['subtasks_history'].items()}, + {k: set(v) for k, v in d['deps_history'].items()}, d['comment']) return t @@ -106,58 +126,41 @@ class Task: 'title_history': self.title.history, 'default_effort_history': self.default_effort.history, 'tags_history': {k: list(v) for k, v in self.tags.history.items()}, - 'subtasks_history': {k: list(v) for k, v in self.subtask_ids.history.items()}, + 'deps_history': {k: list(v) for k, v in self.dep_ids.history.items()}, 'comment': self.comment, } @property - def subtasks(self): - subtasks = [] - for id_ in self.subtask_ids.now: + def deps(self): + deps = [] + for id_ in self.dep_ids.now: if len(id_) == 0: continue - subtasks += [self.db.tasks[id_]] - return subtasks + elif id_ not in self.db.tasks.keys(): + raise PlomException(f'dep referenced on Task {self.id_} not found: {id_}') + deps += [self.db.tasks[id_]] + return deps @property - def subtask_depth(self): - def count_depth(task): + def deps_weight(self): + def count_weight(task): sub_count = 1 - for subtask in task.subtasks: - sub_count += count_depth(subtask) + for dep in task.deps: + sub_count += count_weight(dep) return sub_count - return count_depth(self) + return count_weight(self) - def subtask_loop_checker(self): - def f(subtask_ids_now): - loop_msg = "can't set subtask, would create loop" - for id_ in subtask_ids_now: + def dep_loop_checker(self): + def f(dep_ids_now): + loop_msg = "can't set dep, would create loop" + for id_ in dep_ids_now: if id_ == self.id_: raise PlomException(loop_msg) elif id_ in self.db.tasks.keys(): - subtask = self.db.tasks[id_] - f(subtask.subtask_ids.now) + dep = self.db.tasks[id_] + f(dep.dep_ids.now) return f - def subtasks_sum_maker(self): - def f(f_name, queried_date=None): - subtask_ids_to_check = getattr(self.subtask_ids, f_name) - if queried_date: - subtasks = [self.db.tasks[id_] for id_ in subtask_ids_to_check(queried_date)] - else: - subtasks = [self.db.tasks[id_] for id_ in subtask_ids_to_check] - if len(self.subtasks) > 0: - summe = 0 - for subtask in self.subtasks: - if queried_date: - to_add = getattr(subtask.default_effort, f_name) - summe += to_add(queried_date) - else: - summe += getattr(subtask.default_effort, f_name) - return summe - return None - return f - def matches(self, search): if search is None: return False @@ -165,6 +168,7 @@ class Task: return search in self.title.now or search in self.comment or search in '$'.join(self.tags.now) + class Day: def __init__(self, db, date, comment=''): @@ -194,7 +198,6 @@ class Day: s = 0 for todo in [todo for todo in self.linked_todos.values() if self.date in todo.efforts.keys()]: - # and not todo.children]: day_effort = todo.efforts[self.date] if todo.done: s += day_effort if day_effort else todo.task.default_effort.at(self.date) @@ -206,8 +209,34 @@ class Day: def todos_sum(self): return self._todos_sum() + def sorted_todos(self, done, is_tree_shaped, sort_order, legal_keys): + todos = [t for t in self.linked_todos_as_list if t.visible and t.done == done] + reverse = False + sort_column = sort_order[:] + if sort_order and '-' == sort_order[0]: + reverse = True + sort_column = sort_order[1:] + if sort_column in legal_keys: + todos.sort(key=lambda t: getattr(t, sort_column)) + if reverse: + todos.reverse() + if is_tree_shaped: + def walk_tree(todo, sorted_todos): + todo.deps = [t for t in sorted_todos if t in todo.deps] + for dep in [t for t in sorted_todos if t in todo.deps]: + walk_tree(dep, sorted_todos) + if done: + trunk = [t for t in todos if len([td for td in t.dependers if td.done]) == 0] + else: + trunk = [t for t in todos if len(t.dependers) == 0] + for node in trunk: + walk_tree(node, todos) + todos = trunk + return todos + + -class Todo: +class Todo(TaskLike): def __init__(self, db, @@ -219,17 +248,15 @@ class Todo: importance=1.0, efforts=None, dep_ids=None): - self.id_ = id_ - self.db = db + super().__init__(db, id_, comment) self.task = task self._done = done self.efforts = efforts if efforts else {} - self.comment = comment self.day_tags = day_tags if day_tags else set() self.importance = importance - self.dep_ids = dep_ids if dep_ids else [] - - self.dependers = [] + self._dep_ids = dep_ids if dep_ids else [] + self.already_listed = False + self.been_observed = False @classmethod def from_dict(cls, db, d, id_): @@ -253,11 +280,11 @@ class Todo: 'day_tags': list(self.day_tags), 'importance': self.importance, 'efforts': self.efforts, - 'deps': self.dep_ids} + 'deps': self._dep_ids} @property def title(self): - return self.task.title.at(self.earliest_date) + return self.task.title.at(self.db.selected_date) @property def dated_title(self): @@ -265,11 +292,19 @@ class Todo: @property def deps(self): - return [self.db.todos[id_] for id_ in self.dep_ids] + return [self.db.todos[id_] for id_ in self._dep_ids] @deps.setter def deps(self, deps): - self.dep_ids = [dep.id_ for dep in deps] + self._dep_ids = [dep.id_ for dep in deps] + def f(deps): + loop_msg = "can't set dep, would create loop" + for dep in deps: + if dep == self: + raise PlomException(loop_msg) + else: + f(dep.deps) + f(self.deps) @property def default_effort(self): @@ -317,6 +352,20 @@ class Todo: paths += [path + [depender]] return paths + @property + def shortened_depender_paths(self): + new_paths = [] + for path in self.depender_paths: + new_path = [] + for i, step in enumerate(path): + next_step = None if len(path) <= i+1 else path[i+1] + for distinct_path in new_paths: + if len(distinct_path) >= i+2 and distinct_path[i+1] == next_step: + step = None + new_path += [step] + new_paths += [new_path] + return new_paths + @property def all_days_effort(self): total = 0 @@ -349,6 +398,13 @@ class Todo: def day_effort(self): return self.efforts[self.db.selected_date] + @property + def effort_at_selected_date(self): + if self.db.selected_date in self.efforts.keys() and self.day_effort is not None: + return self.day_effort + else: + return self.task.default_effort.then + @property def day(self): return self.db.days[self.earliest_date] @@ -367,20 +423,37 @@ class Todo: def latest_date(self): return self.sorted_effort_dates[-1] + @property + def has_dependers(self): + return len(self.dependers) > 0 + + @property + def has_deps(self): + return len(self.deps) > 0 + + @property + def sort_done(self): + return self.day_effort if self.day_effort else 0 + + @property + def family_effort(self): + return self.effort_at_selected_date + self.dep_efforts + + def observe(self): + self.been_observed = True + return '' + + class TodoDB(PlomDB): def __init__(self, selected_date=None, tag_filter_and = None, - tag_filter_not = None, - hide_unchosen=False, - hide_done=False): + tag_filter_not = None): self.selected_date = selected_date if selected_date else today_date() self.tag_filter_and = tag_filter_and if tag_filter_and else [] self.tag_filter_not = tag_filter_not if tag_filter_not else [] - self.hide_unchosen = hide_unchosen - self.hide_done = hide_done self.days = {} self.tasks = {} @@ -398,7 +471,7 @@ class TodoDB(PlomDB): for tag in t.tags.now: self.t_tags.add(tag) for task in self.tasks.values(): - for dep in task.subtasks: + for dep in task.deps: dep.dependers += [task] for id_, todo_dict in d['todos'].items(): @@ -417,7 +490,7 @@ class TodoDB(PlomDB): self.add_day(date) self.days[date].linked_todos_as_list += [todo] - self.set_visibilities() + # self.set_visibilities() def to_dict(self): d = {'tasks': {}, 'days': {}, 'todos': {}} @@ -459,12 +532,12 @@ class TodoDB(PlomDB): self.tasks[id_] = t return t - def update_task(self, id_, title, default_effort, tags, subtask_ids, comment): + def update_task(self, id_, title, default_effort, tags, dep_ids, comment): task = self.tasks[id_] if id_ in self.tasks.keys() else self.add_task(id_) task.title.set(title) task.default_effort.set(default_effort) task.tags.set(tags) - task.subtask_ids.set(subtask_ids) + task.dep_ids.set(dep_ids) task.comment = comment return task @@ -475,7 +548,7 @@ class TodoDB(PlomDB): elif task and efforts: todo = Todo(self, id_, task, efforts=efforts) deps = [] - for dep_task in task.subtasks: + for dep_task in task.deps: # if Todo expects dependencies, adopt any compatibles found in DB.selected_date # before creating new depended Todos dep_todo = None @@ -489,7 +562,8 @@ class TodoDB(PlomDB): link_into_day=link_into_day, adopt_if_possible=adopt_if_possible) deps += [dep_todo] - todo.dep_ids = [dep.id_ for dep in deps] + # todo.dep_ids = [dep.id_ for dep in deps] + todo.deps = deps self.todos[id_] = todo if link_into_day: self.selected_day.linked_todos_as_list += [todo] @@ -527,7 +601,7 @@ class TodoDB(PlomDB): for date in dates_to_delete: self.delete_effort(todo, date, force=True) for depender in todo.dependers: - depender.dep_ids.remove(todo.id_) + depender._dep_ids.remove(todo.id_) del self.todos[id_] def delete_task(self, id_): @@ -547,8 +621,20 @@ class TodoDB(PlomDB): def show_calendar(self, start_date_str, end_date_str): self.tag_filter_and = ['calendar'] self.tag_filter_not = ['deleted'] - self.set_visibilities() - start_date_obj, end_date_obj = self.get_limit_days_from_date_strings(start_date_str, end_date_str) + + todays_date_obj = datetime.strptime(today_date(), DATE_FORMAT) + yesterdays_date_obj = todays_date_obj - timedelta(1) + def get_day_limit_obj(index, day_limit_string): + date_obj = datetime.strptime(sorted(self.days.keys())[index], DATE_FORMAT) + if day_limit_string and len(day_limit_string) > 0: + if day_limit_string in {'today', 'yesterday'}: + date_obj = todays_date_obj if day_limit_string == 'today' else yesterdays_date_obj + else: + date_obj = datetime.strptime(day_limit_string, DATE_FORMAT) + return date_obj + start_date_obj = get_day_limit_obj(0, start_date_str) + end_date_obj = get_day_limit_obj(-1, end_date_str) + days_to_show = {} for n in range(int((end_date_obj - start_date_obj).days) + 1): date_obj = start_date_obj + timedelta(n) @@ -566,27 +652,28 @@ class TodoDB(PlomDB): start_date=start_date_str, end_date=end_date_str) - def show_do_todos(self, sort_order=None): - prev_date_str, next_date_str = self.neighbor_dates() + def show_day_todos(self, undone_sort_order=None, done_sort_order=None, is_tree_shaped=False): + legal_undone_sort_keys = {'title', 'sort_done', 'default_effort', 'importance'} + legal_done_sort_keys = {'title', 'effort_at_selected_date', 'family_effort'} + + current_date = datetime.strptime(self.selected_date, DATE_FORMAT) + prev_date = current_date - timedelta(days=1) + prev_date_str = prev_date.strftime(DATE_FORMAT) + next_date = current_date + timedelta(days=1) + next_date_str = next_date.strftime(DATE_FORMAT) + adoptable_past_todos = [] - for todo in self.todos.values(): - if todo.done\ - or (not todo.visible)\ - or todo.earliest_date >= self.selected_date: - continue - adoptable_past_todos += [todo] - todos = [t for t in self.selected_day.linked_todos_as_list - if t.visible] - # and not t.deps] - if sort_order == 'title': - todos.sort(key=lambda t: t.task.title.then) - elif sort_order == 'done': - todos.sort(key=lambda t: t.day_effort if t.day_effort else t.default_effort if t.done else 0, reverse=True) - elif sort_order == 'default_effort': - todos.sort(key=lambda t: t.default_effort, reverse=True) - elif sort_order == 'importance': - todos.sort(key=lambda t: t.importance, reverse=True) - return j2env.get_template('do_todos.html').render( + for todo in [t for t in self.todos.values() + if t.visible + and (not t.done) + and t.earliest_date < self.selected_date]: + adoptable_past_todos += [todo] + undone_todos = self.selected_day.sorted_todos(False, is_tree_shaped, undone_sort_order, + legal_undone_sort_keys) + done_todos = self.selected_day.sorted_todos(True, is_tree_shaped, done_sort_order, + legal_done_sort_keys) + + return j2env.get_template('day_todos.html').render( day=self.selected_day, tags=self.t_tags, filter_and=self.tag_filter_and, @@ -595,26 +682,21 @@ class TodoDB(PlomDB): adoptable_past_todos=adoptable_past_todos, next_date=next_date_str, all_tasks=[t for t in self.tasks.values()], - todos=todos, - sort=sort_order, - hide_done=self.hide_done) + undone_todos=undone_todos, + done_todos=done_todos, + is_tree_shaped=is_tree_shaped, + undone_sort=undone_sort_order, + done_sort=done_sort_order) - def show_todo(self, id_, start_date, end_date): + def show_todo(self, id_): todo = self.todos[id_] filtered_tasks = [t for t in self.tasks.values() if t != todo.task] filtered_todos = [t for t in self.todos.values() - if t != todo] - - # if going into the past, only allow 3-day ranges - start_day, end_day = self.get_limit_days_from_date_strings(start_date, end_date) - if start_day < datetime.now() - timedelta(days=2): - end_day = start_day + timedelta(days=3) - end_date = end_day.strftime(DATE_FORMAT) - legal_dates = [] - for n in range(int((end_day - start_day).days) + 1): - day = start_day + timedelta(n) - legal_dates += [day.strftime(DATE_FORMAT)] + if t != todo + and t not in todo.deps] + + legal_dates = list(todo.efforts.keys()) date_filtered_todos = [] for date in legal_dates: for filtered_todo in filtered_todos: @@ -623,14 +705,25 @@ class TodoDB(PlomDB): if date in filtered_todo.efforts.keys(): date_filtered_todos += [filtered_todo] + dep_slots = [] + for dep in todo.task.deps: + dep_slots += [{'task': dep, + 'todos': [t for t in todo.deps if t.task == dep]}] + + suggested_todos = {} + for dep in todo.task.deps: + suggested_todos[dep.id_] = [t for t in date_filtered_todos if t.task.id_ == dep.id_] + additional_deps = [t for t in todo.deps if not t.task in todo.task.deps] + return j2env.get_template('todo.html').render( tags=self.t_tags, todo=todo, filtered_todos=date_filtered_todos, filtered_tasks=filtered_tasks, - dep_todos=todo.deps, - start_date=start_date, - end_date=end_date) + dep_slots=dep_slots, + suggested_todos=suggested_todos, + additional_deps=additional_deps, + dep_todos=todo.deps) def show_task(self, id_): task = self.tasks[id_] if id_ else self.add_task() @@ -638,7 +731,8 @@ class TodoDB(PlomDB): task.default_effort.set(1.0) filtered_tasks = [t for t in self.tasks.values() if t != task - and (t not in task.subtasks)] + and (t not in task.deps)] + return j2env.get_template('task.html').render( selected_date=self.selected_date, tags=self.t_tags, @@ -649,12 +743,19 @@ class TodoDB(PlomDB): filtered_tasks = [] for task in [t for t in self.tasks.values() if (not search) or t.matches(search)]: filtered_tasks += [task] - if sort_order == 'title': + reverse = False + sort_column = sort_order + if sort_order and '-' == sort_order[0]: + reverse = True + sort_column = sort_order[1:] + if sort_column == 'title': filtered_tasks.sort(key=lambda t: t.title.now) - elif sort_order == 'default_effort': - filtered_tasks.sort(key=lambda t: t.default_effort.now, reverse=True) - elif sort_order == 'depth': - filtered_tasks.sort(key=lambda t: t.subtask_depth, reverse=True) + elif sort_column == 'default_effort': + filtered_tasks.sort(key=lambda t: t.default_effort.now) + elif sort_column == 'weight': + filtered_tasks.sort(key=lambda t: t.deps_weight) + if reverse: + filtered_tasks.reverse() return j2env.get_template('tasks.html').render( sort=sort_order, tasks=filtered_tasks, @@ -663,90 +764,6 @@ class TodoDB(PlomDB): filter_not=self.tag_filter_not, search=search) - # def show_pick_tasks(self, search, hide_chosen_tasks, sort_order=None): - # prev_date_str, next_date_str = self.neighbor_dates() - - # chosen_todos = self.selected_day.linked_todos_as_list - - # relevant_todos = [] - # for todo in self.todos.values(): - # if todo.done\ - # or (not todo.visible)\ - # or (not todo.matches(search))\ - # or todo.earliest_date >= self.selected_date: - # continue - # relevant_todos += [todo] - - # filtered_tasks = [] - # chosen_tasks = [todo.task for todo in self.selected_day.linked_todos_as_list] - # for uuid, task in self.tasks.items(): - # if (not task.visible)\ - # or (not task.matches(search))\ - # or (hide_chosen_tasks and task in chosen_tasks): - # continue - # filtered_tasks += [task] - - # if sort_order == 'title': - # chosen_todos.sort(key=lambda t: t.title) - # relevant_todos.sort(key=lambda t: t.dated_title) - # tasks.sort(key=lambda t: t.title.then) - # elif sort_order == 'effort': - # chosen_todos.sort(key=lambda t: - # t.day_effort if t.day_effort else (t.default_effort if t.done else 0), - # reverse=True) - # relevant_todos.sort(key=lambda t: t.all_days_effort, reverse=True) - # filtered_tasks.sort(key=lambda t: t.default_effort.then, reverse=True) - - # return j2env.get_template('pick_tasks.html').render( - # sort=sort_order, - # tags=self.t_tags, - # chosen_todos=chosen_todos, - # filter_and=self.tag_filter_and, - # filter_not=self.tag_filter_not, - # day=self.selected_day, - # prev_date=prev_date_str, - # next_date=next_date_str, - # all_tasks=[t for t in self.tasks.values()], - # filtered_tasks=filtered_tasks, - # hide_chosen_tasks=hide_chosen_tasks, - # relevant_todos=relevant_todos, - # search=search) - - # helpers - - def set_visibilities(self): - for uuid, t in self.tasks.items(): - t.visible = len([tag for tag in self.tag_filter_and if not tag in t.tags.now]) == 0\ - and len([tag for tag in self.tag_filter_not if tag in t.tags.now]) == 0\ - and ((not self.hide_unchosen) or uuid in self.selected_day.todos.keys()) - for todo in self.todos.values(): - todo.visible = len([tag for tag in self.tag_filter_and if not tag in todo.day_tags | todo.task.tags.now ]) == 0\ - and len([tag for tag in self.tag_filter_not if tag in todo.day_tags | todo.task.tags.now ]) == 0\ - and ((not self.hide_done) or (not todo.done)) - - def get_limit_days_from_date_strings(self, start_date_str, end_date_str): - todays_date_obj = datetime.strptime(today_date(), DATE_FORMAT) - yesterdays_date_obj = todays_date_obj - timedelta(1) - def get_day_limit_obj(index, day_limit_string): - date_obj = datetime.strptime(sorted(self.days.keys())[index], DATE_FORMAT) - if day_limit_string and len(day_limit_string) > 0: - if day_limit_string in {'today', 'yesterday'}: - date_obj = todays_date_obj if day_limit_string == 'today' else yesterdays_date_obj - else: - date_obj = datetime.strptime(day_limit_string, DATE_FORMAT) - return date_obj - start_date_obj = get_day_limit_obj(0, start_date_str) - end_date_obj = get_day_limit_obj(-1, end_date_str) - return start_date_obj, end_date_obj - - def neighbor_dates(self): - current_date = datetime.strptime(self.selected_date, DATE_FORMAT) - prev_date = current_date - timedelta(days=1) - prev_date_str = prev_date.strftime(DATE_FORMAT) - next_date = current_date + timedelta(days=1) - next_date_str = next_date.strftime(DATE_FORMAT) - return prev_date_str, next_date_str - class ParamsParser: @@ -755,19 +772,22 @@ class ParamsParser: self.params = parse_qs(parsed_url_query) self.cookie_db = cookie_db - def get(self, key, default=None): - boolean = bool == type(default) + def get(self, key, default=None, as_bool=False): + # boolean = bool == type(default) param = self.params.get(key, [default])[0] - if boolean: - param = param != '0' + if as_bool: + if param == '0': + param = False + elif param is not None: + param = True return param def cookie_key_from_params_key(self, prefix, key): return f'{prefix}:{key}' if prefix else key - def get_cookied(self, key, default=None, prefix=None): + def get_cookied(self, key, default=None, prefix=None, as_bool=False): cookie_key = self.cookie_key_from_params_key(prefix, key) - param = self.get(key, default) + param = self.get(key, default, as_bool) if param == '-': param = None if cookie_key in self.cookie_db.keys(): @@ -792,6 +812,7 @@ class ParamsParser: return params + class PostvarsParser: def __init__(self, postvars): @@ -925,49 +946,26 @@ class TodoHandler(PlomHandler): raise PlomException('will not remove Task describing existing Todos') if postvars.get('title', '')\ or postvars.get_all('tag', [])\ - or postvars.get_all('subtask', [])\ + or postvars.get_all('dep', [])\ or postvars.get('comment', ''): raise PlomException('will not remove Task of preserve-worthy values') db.delete_task(task_id) elif postvars.has('update'): + dep_ids = postvars.get_all('dep', []) + for id_ in [id_ for id_ in dep_ids if not id_ in db.tasks.keys()]: + raise PlomException('submitted illegal dep ID') task = db.update_task( id_=task_id, title=postvars.get('title', ''), default_effort=postvars.get('default_effort', float_if_possible=True), tags=postvars.get_all('tag', []), - subtask_ids=postvars.get_all('subtask', []), + dep_ids=dep_ids, comment=postvars.get('comment', '')) if postvars.has('add_as_todo'): db.add_todo(task=task, efforts={postvars.get('selected_date'): None}) redir_params += [('id', task_id)] - # elif 'pick_tasks' == site: - # redir_params += [('hide_chosen_tasks', int(postvars.has('hide_chosen_tasks')))] - # if postvars.has('update'): - # db.selected_date = postvars.get('date') - # todos_to_shrink = [] - # todos_to_delete = [] - # for todo in db.selected_day.linked_todos_as_list: - # if todo.visible and not todo.id_ in postvars.get_all('chosen_todo', []): - # if len(todo.comment) > 0\ - # or len(todo.day_tags) > 0\ - # or not todo.is_effort_removable(db.selected_date): - # raise PlomException('will not remove effort of preserve-worthy values') - # if len(todo.efforts) > 1: - # todos_to_shrink += [todo] - # else: - # todos_to_delete += [todo] - # for todo in todos_to_shrink: - # db.delete_effort(todo, db.selected_date) - # for todo in todos_to_delete: - # db.delete_todo(todo.id_) - # for id_ in postvars.get_all('choose_task', []): - # db.add_todo(task=db.tasks[id_], efforts={db.selected_date: None}) - # for id_ in postvars.get_all('choose_todo', []): - # db.todos[id_].efforts[db.selected_date] = None - - elif 'do_todos' == site: - redir_params += [('hide_done', int(postvars.has('hide_done')))] + elif 'day_todos' == site: if postvars.has('update'): db.selected_date = postvars.get('date') redir_params += [('date', db.selected_date)] @@ -1025,47 +1023,40 @@ class TodoHandler(PlomHandler): params = ParamsParser(parsed_url.query, cookie_db) selected_date = tag_filter_and = tag_filter_not = None - hide_unchosen = hide_done = False - return_to = params.get('return_to', '') - if site in {'do_todos', 'calendar', 'task'}: + if site in {'day_todos', 'calendar', 'task'}: selected_date = params.get_cookied('date') - if site in {'do_todos', 'tasks'}: + if site in {'day_todos', 'tasks'}: tag_filter_and = params.get_cookied_chain('and_tag', prefix=site) tag_filter_not = params.get_cookied_chain('not_tag', prefix=site) - if 'do_todos' == site: - hide_done = params.get('hide_done', False) - db = TodoDB(selected_date, tag_filter_and, tag_filter_not, hide_unchosen, hide_done) + db = TodoDB(selected_date, tag_filter_and, tag_filter_not) if site in {'todo', 'task'}: id_ = params.get('id') - if site in {'do_todos', 'tasks'}: - sort_order = params.get_cookied('sort', prefix=site) - if site in {'', 'calendar', 'todo'}: - start_date = params.get_cookied('start', prefix=site) - end_date = params.get_cookied('end', prefix=site) if 'reset_cookie' == site: cookie_db = { # sensible defaults - # params.cookie_key_from_params_key('pick_tasks', 'and_tag'): ['default'], - # params.cookie_key_from_params_key('pick_tasks', 'not_tag'): ['ignore'], + params.cookie_key_from_params_key('day_todos', 'tree'): True, params.cookie_key_from_params_key('todo', 'and_tag'): ['default'], params.cookie_key_from_params_key('todo', 'not_tag'): ['ignore'], params.cookie_key_from_params_key('todo', 'start'): 'yesterday', params.cookie_key_from_params_key('todo', 'end'): 'today'} page = db.show_message('cookie unset!') - elif 'do_todos' == site: - page = db.show_do_todos(sort_order) - # elif 'pick_tasks' == site: - # hide_chosen_tasks = params.get('hide_chosen_tasks', False) - # page = db.show_pick_tasks(search, hide_chosen_tasks, sort_order) + elif 'day_todos' == site: + is_tree_shaped = params.get_cookied('tree', prefix=site, as_bool=True) + undone_sort_order = params.get_cookied('undone_sort', prefix=site) + done_sort_order = params.get_cookied('done_sort', prefix=site) + page = db.show_day_todos(undone_sort_order, done_sort_order, is_tree_shaped) elif site == 'todo': - page = db.show_todo(id_, start_date, end_date) + page = db.show_todo(id_) elif 'task' == site: page = db.show_task(id_) elif 'tasks' == site: + sort_order = params.get_cookied('sort', prefix=site) search = params.get('search', '') page = db.show_tasks(search, sort_order) elif 'add_task' == site: page = db.show_task(None) else: # 'calendar' == site + start_date = params.get_cookied('start', prefix=site) + end_date = params.get_cookied('end', prefix=site) page = db.show_calendar(start_date, end_date) self.set_cookie(config['cookie_name'], config['cookie_path'], cookie_db) diff --git a/todo_templates/base.html b/todo_templates/base.html index a2d05da..1977c1f 100644 --- a/todo_templates/base.html +++ b/todo_templates/base.html @@ -9,20 +9,21 @@ table.alternating tr:nth-child(odd) { background-color: white; } th, td { vertical-align: top; text-align: left} +th.desc { background: linear-gradient(to bottom, white, grey); } +th.asc { background: linear-gradient(to top, white, grey); } input[type="number"], td.number { text-align: right; } input[type="checkbox"] { height: 1.3em; width: 1.3em; } -th.desc { background: linear-gradient(to bottom, white, grey); } input[type="submit"] { background-color: #cccccc; } -button { background-color: #cccccc; } input[type="submit"].update { background-color: #aaffaa; } input[type="submit"].delete { background-color: #ff7777; } div.delete { float: right; } +button { background-color: #cccccc; } {% block css %} {% endblock %} -tasks: review add | day: -do todos +tasks: review / add +| day todos | calendar | reset cookie
diff --git a/todo_templates/calendar.html b/todo_templates/calendar.html index bc77ccd..343019a 100644 --- a/todo_templates/calendar.html +++ b/todo_templates/calendar.html @@ -1,13 +1,18 @@ {% extends 'base.html' %} + + {% block css %} #filter { margin-bottom: 1em; } tr.month_row td { color: white; background-color: #555555; text-align: center; } tr.week_row td { height: 0.1em; background-color: black; } tr.day_row td { background-color: #cccccc; } span.selected_date { font-weight: bold; } +span.todos_sum { white-space: pre; } {% endblock %} + + {% block content %}

calendar

@@ -36,9 +41,9 @@ to: -{{ day.weekday }} {{ date }} +{{ day.weekday }} {{ date }} -|{{ '{:5.1f}'.format(day.todos_sum)}}| +|{{ '{:5.1f}'.format(day.todos_sum)}}| {{ day.comment|e }} @@ -48,7 +53,7 @@ to: {% if "cancelled" in todo.tags %}{% endif %} -[{% if todo.done and not "cancelled" in todo.tags %}✓{% else %} {% endif %}] +{{ macros.doneness_string(todo, true) }} {% if "deadline" in todo.tags %}DEADLINE: {% endif %} {{ todo.title|e }} diff --git a/todo_templates/day_todos.html b/todo_templates/day_todos.html new file mode 100644 index 0000000..8cf87fb --- /dev/null +++ b/todo_templates/day_todos.html @@ -0,0 +1,240 @@ +{% extends 'base.html' %} + + + +{% block css %} +td.checkbox { text-align: center; } +td { vertical-align: middle; } +td button { padding: 0em; } +th.centered { text-align: center; } +ul { padding-left: 1.5em; margin: 0; } +details > summary.todo { + list-style-type: ' '; +} +details > summary.has_dependers { + list-style-type: '[+]:'; +} +details[open] > summary.has_dependers { + list-style-type: '[▼]:'; +} +details > summary.has_deps::after { + content: ':[+]'; +} +details[open] > summary.has_deps::after { + content: ':[▼]'; +} +table.undone_todos tr.deps_undone { + background-color: #cccccc; +} +details.adoptables { + margin-bottom: 1em; +} +details.adoptables summary span { + background-color: #cccccc; +} +table.undone_todos tr td { + border-bottom: 1px dotted black; +} +td.left { text-align: left; } +td.unbreakable { white-space: nowrap; } +{% endblock %} + + + +{% macro todo_title_expandable(todo, show_deps_doneness, ignore=0) %} +{% if todo.has_dependers or todo.has_deps %} +
+ +{% else %} +     +{% endif %} +{{todo.title|e}} +{% if todo.has_dependers or todo.has_deps %} + +{% if todo.has_dependers %} +dependers: +
    +{% for path in todo.depender_paths %} +
  • {% for depender_todo in path %}{{ depender_todo.title|e }}{% if not loop.last %}:{% endif %}{% endfor %} +{% endfor %} +
+{% endif %} +{% if todo.has_deps %} +depends on: +
    +{% for dep_todo in todo.deps %} +
  • +{% if show_deps_doneness == true %}{{ macros.doneness_string(dep_todo) }}{% endif %} +{{ dep_todo.title|e }}{% if dep_todo.has_deps %}:+{% endif %} +{% endfor %} +
+{% endif %} +
+{% endif %} +{% endmacro %} + + + +{% macro todo_title_as_tree_node(todo, indent) %} +{% for i in range(indent-1) %}   {% endfor %} +{% if indent>0 %} +{% endif %} +{% if todo.been_observed %}({% endif %}{{todo.title}}{% if todo.been_observed %}){% endif %} +{% endmacro %} + + + +{% macro draw_undone_todo_row(todo, title_drawer, indent_or_doneness) %} + +{% if todo.already_listed %} + + + + +{{ title_drawer(todo, indent_or_doneness ) }} + + +{% else %} + + + + + + + + + + + +{{ title_drawer(todo, indent_or_doneness) }} + + + + +{% endif %} + +{% endmacro %} + + + +{% macro draw_done_todo_row(todo, title_drawer, indent) %} + +{{ '{:4.1f}'.format(todo.effort_at_selected_date) }} +{{ '{:4.1f}'.format(todo.effort_at_selected_date + todo.dep_efforts) }} + +{{ title_drawer(todo, indent) }} + + + +{{ todo.comment }} + +{% endmacro %} + + + +{% macro draw_todo_rows(todos, is_tree_shaped, todo_row_drawer, indent, show_deps_doneness=false) %} +{% for todo in todos %} +{% if is_tree_shaped %} +{{ todo_row_drawer(todo, todo_title_as_tree_node, indent) }} +{% if not todo.been_observed and todo.deps %} +{{ draw_todo_rows(todo.deps, is_tree_shaped, todo_row_drawer, indent+1) }} +{% endif %} +{% else %} +{{ todo_row_drawer(todo, todo_title_expandable, show_deps_doneness) }} +{% endif %} +{{ todo.observe() }} +{% endfor %} +{% endmacro %} + + + +{% block content %} +

day todos

+ + +{% include 'tagfilters.html' %} +
+ +

+| prev | {{day.date}} | next | +comment: + + +| show as {% if is_tree_shaped %}flat|tree{% else %}flat|tree{% endif %} +

+ +

undone

+

+task quick-add: +don't adopt, make new: +

+{{ macros.datalist_tasks(all_tasks, with_weight=true) }} + +{% if adoptable_past_todos %} +
+there are adoptable/unfinished past todos ({{adoptable_past_todos|count}}) + + + + + + + + + +{% endfor %} +
adopt?datetitlecomment
{{todo.earliest_date}}{{todo.title|e}}{{todo.comment|e}}
+
+{% endif %} + +{% if undone_todos %} + + +{{ macros.sort_head(undone_sort, "sort_done", "done", "undone_sort") }} +{{ macros.sort_head(undone_sort, "default_effort", "effort", "undone_sort") }} +{{ macros.sort_head(undone_sort, "importance", "importance", "undone_sort") }} +{{ macros.sort_head(undone_sort, "title", "todo", "undone_sort") }} + + +{{ draw_todo_rows(undone_todos, is_tree_shaped, draw_undone_todo_row, 0, show_deps_doneness=true) }} +{% endif %} + +
comment
+ + + +{% if done_todos %} +

done

+ + +{{ macros.sort_head(done_sort, "effort_at_selected_date", "single
effort", "done_sort") }} +{{ macros.sort_head(done_sort, "family_effort", "family
effort", "done_sort") }} +{{ macros.sort_head(done_sort, "title", "todo", "done_sort") }} + + +{{ draw_todo_rows(done_todos, is_tree_shaped, draw_done_todo_row, 0) }} +
comment
+{% endif %} + +{% include 'watch_form.html' %} + +{% endblock %} diff --git a/todo_templates/do_todos.html b/todo_templates/do_todos.html deleted file mode 100644 index 25211f0..0000000 --- a/todo_templates/do_todos.html +++ /dev/null @@ -1,161 +0,0 @@ -{% extends 'base.html' %} - -{% block css %} -td.number, td.checkbox { text-align: center; } -td { vertical-align: middle; } -td button { padding: 0em; } -th.centered { text-align: center; } -ul { margin: 0; } -details > summary { - list-style-type: none; -} -details > summary.has_dependers { - list-style-type: '▶'; -} -details[open] > summary.has_dependers { - list-style-type: '▼'; -} -details > summary.has_deps::after { - content: '▶'; -} -details[open] > summary.has_deps::after { - content: '▼'; -} -{% endblock %} - -{% block content %} -

do todos

- -
-{% include 'tagfilters.html' %} -
- hide done - -

-| prev | {{day.date}} | next | -comment: - - -

- -

-task quick-add: -don't adopt, make new: -

- -{% for task in all_tasks %} - -{% endfor %} - - -{% if adoptable_past_todos %} -

-

- -there are adoptable/unfinished past todos ({{adoptable_past_todos|count}}) - - - - - - - - - - -{% endfor %} -
adopt?datetitlecomment
{{todo.earliest_date}}{{todo.title|e}}{{todo.comment|e}}
-
-

-{% endif %} - - - - - - - - - - -{% for todo in todos %} - - - - - - - - -{% endfor %} - -
-done - -effort - -importance - -todo -comment
- - - - - - -{% if todo.dependers|length > 0 or todo.deps|length > 0 %} -
- -{% endif %} -{{todo.title|e}} -{% if todo.dependers|length > 0 or todo.deps|length > 0 %} - -{% if todo.dependers|length > 0 %} -dependers: -
    -{% for path in todo.depender_paths %} -
  • {% for depender_todo in path %}{{ depender_todo.title|e }} ▶ {% endfor %}… -{% endfor %} -
-{% endif %} -{% if todo.deps|length > 0 %} -depends on: -
    -{% for dep_todo in todo.deps %} -
  • [{% if dep_todo.done %}✓{% else %} {% endif %}] {{ dep_todo.title|e }}{% if dep_todo.deps|length > 0 %} ▶{% endif %} -{% endfor %} -
-{% endif %} -
-{% endif %} -
- -
- -
- -{% include 'watch_form.html' %} - -{% endblock %} diff --git a/todo_templates/pick_tasks.html b/todo_templates/pick_tasks.html deleted file mode 100644 index 28919df..0000000 --- a/todo_templates/pick_tasks.html +++ /dev/null @@ -1,136 +0,0 @@ -{% extends 'base.html' %} - -{% block css %} -#pick_upper, #pick_lower { margin-right: 1em; } -{% endblock %} - -{% block content %} -

pick todos for day

- -
- -

-prev | {{day.date}} | next | {{day.comment}} -

- - - - - - - - - - -{% for task in all_tasks %} - -{% endfor %} - - - - - - - - - -{% for todo in chosen_todos %} - - - - - - -{% endfor %} - - - - - -{% for todo in relevant_todos %} - - - - - - -{% endfor %} - - - - - -{% for task in filtered_tasks %} - - - - - - -{% endfor %} - -
task quick-add:
do -effort - -what -comment
- - -{% if todo.day_effort %}{{todo.day_effort}} {% else %}({{todo.default_effort}}){% endif %}{% if todo.done and not "cancelled" in todo.contemporary_tags%}✓{% else %} {% endif %} - - -{% if "cancelled" in todo.tags.now %}{% endif %} -{{todo.path|e}}{{todo.title|e}} -{%if "cancelled" in todo.tags.now %}{% endif %} - - -{{todo.comment|e}} -
earlier todos to continue
- - -{{todo.all_days_effort}}/{{todo.default_effort}} - -{{todo.dated_title|e}} - -{{todo.comment|e}} -
tasks
- - -({{task.default_effort.then}})  - -{{ task.title.then|e }} - -{{task.comment|e}} -
- -
-{% include 'tagfilters.html' %} -
- hide chosen tasks
-search: - -
- -{% include 'watch_form.html' %} - -{% endblock %} diff --git a/todo_templates/task.html b/todo_templates/task.html index 7284f1b..c26d33a 100644 --- a/todo_templates/task.html +++ b/todo_templates/task.html @@ -1,11 +1,31 @@ {% extends 'base.html' %} + + {% block css %} tr.toplevel th { padding-right: 1em; } tr.toplevel td, tr.toplevel th { padding-top: 1em; } tr.lowlevel td, tr.lowlevel th { padding-top: 0em; } {% endblock %} + + +{% macro draw_task(task) %} +{{task.title.now}} +{% endmacro %} + + + +{% macro task_with_deps(task, indent) %} +{% for i in range(indent) %}  {% if loop.last %}+{% endif %}{% endfor %} +{{ draw_task(task) }}
+{% for task in task.deps %} +{{ task_with_deps(task, indent+1) }} +{% endfor %} +{% endmacro %} + + + {% block content %}

edit task

@@ -44,9 +64,6 @@ tr.lowlevel td, tr.lowlevel th { padding-top: 0em; } default effort -{% if task.subtasks %} -{{ task.default_effort.now }} -{% else %}
history @@ -56,7 +73,6 @@ tr.lowlevel td, tr.lowlevel th { padding-top: 0em; } {% endfor %}
-{% endif %} @@ -75,45 +91,67 @@ add: {{ macros.tagselection(submit_name='tag', selected_tags=task.tags.now, all_ -{% if task.parents %} +{% if task.dependers %} -parents +dependers
    -{% for parent in task.parents %} +{% for parent in task.dependers %}
  • {{parent.title.now}} {% endfor %}
{% endif %} - + children -{% if task.subtasks %} +{% if task.deps %} -{% for subtask in task.subtasks %} +{% for dep in task.deps %} {% endfor %}
- + -{{subtask.title.now}} +{% if dep.deps %} +
+ +{% endif %} +{{ draw_task(dep)}} +{% if dep.deps %} + +{% for s in dep.deps %} +{{ task_with_deps(s, 1) }} +{% endfor %} +
+{% endif %}
{% endif %} -
-add: +add: - -{% for subtask in filtered_tasks %} - +{{ macros.datalist_tasks(filtered_tasks) }} + +{% if task.deps %} + +as chain + + +{% for dep in task.deps_chain %} + + + + {% endfor %} - +
{{dep.deps_depth}}{{dep.title.now}}
+ + +{% endif %} diff --git a/todo_templates/tasks.html b/todo_templates/tasks.html index 90f4358..cd5ef0f 100644 --- a/todo_templates/tasks.html +++ b/todo_templates/tasks.html @@ -21,15 +21,9 @@ match: - - - +{{ macros.sort_head(sort, "default_effort", "effort") }} +{{ macros.sort_head(sort, "weight", "weight") }} +{{ macros.sort_head(sort, "title", "task") }} {% for t in tasks %} @@ -39,7 +33,7 @@ match: {{ '{:5.1f}'.format(t.default_effort.now) }} diff --git a/todo_templates/todo.html b/todo_templates/todo.html index 88fa72b..5aaf8a0 100644 --- a/todo_templates/todo.html +++ b/todo_templates/todo.html @@ -1,12 +1,69 @@ {% extends 'base.html' %} + + {% block css %} tr.toplevel th { padding-right: 1em; } td.center { text-align: center; } tr.toplevel td, tr.toplevel th { padding-top: 1em; } tr.lowlevel td, tr.lowlevel th { padding-top: 0em; } +tr.grey td { background-color: #cccccc; } {% endblock %} + + +{% macro draw_todo(todo) %}{{todo.title}}{% if todo.comment %}({{todo.comment|e}}){% endif %}{% endmacro %} + + + +{% macro task_with_deps(task, indent) %} +{% for i in range(indent) %}  {% endfor %}+ +({{task.title.then}})
+{% for t in task.deps %} +{{ task_with_deps(t, indent+1) }} +{% endfor %} +{% endmacro %} + + + +{% macro todo_with_deps(todo, indent) %} +{% for i in range(indent) %}   {% endfor %}{{ macros.doneness_string(todo) }} {{ draw_todo(todo) }}
+{% for dep in todo.deps %} +{% if dep.been_observed %} +{% for i in range(indent+1) %}   {% endfor %}{{ macros.doneness_string(dep) }} ({{ draw_todo(dep) }})
+{% else %} +{{ todo_with_deps(dep, indent+1) }} +{% endif %} +{% endfor %} +{{ todo.observe() }} +{% endmacro %} + + + +{% macro draw_deps(deps) %} +{% for t in deps %} + + + + +{{ t.observe() }} + +{% endfor %} +{% endmacro %} + + + {% block content %}

edit todo

@@ -77,9 +134,8 @@ done
@@ -88,46 +144,119 @@ new: {% endif %} - + + + + + + + + + + + + +{{ macros.datalist_tasks(filtered_tasks) }} + + + +
-effort - -depth - -todo -tags
-{{ '{:5.1f}'.format(t.subtask_depth) }} +{{ '{:5.1f}'.format(t.subtask_weight) }} {{ t.title.now|e }}
{{ macros.doneness_string(t) }} +{% if t.deps and not t.been_observed %} +
+{{ draw_todo(t) }} +{% for dep in t.deps %} +{{ todo_with_deps(dep, 0) }} +{% endfor %} +
+{% else %} +{{ draw_todo(t) }} +{% endif %} +
tags -new: +new: {{ macros.tagselection(submit_name='tag', selected_tags=todo.day_tags, all_tags=tags) }} {% for tag in todo.task.tags.now | sort %}{% endfor %} -{{ macros.tagselection(submit_name='tag', selected_tags=todo.day_tags, all_tags=tags) }}
dependers -
    -{% for depender in todo.dependers %} -
  • {{depender.title}} + +{% for path in todo.shortened_depender_paths %} + + + {% endfor %} - +
    +{% if not path[0] %}[…]
    {% endif %} +{% for step in path %} +{% if step %} +{% if step.dependers %}➛ {% endif %}{{step.title}}
    +{% endif %} +{% endfor %}
dependenciessub-todos -{% if todo.deps %} + +{% for dep_slot in dep_slots %} +{% if dep_slot.todos %} +{{ draw_deps(dep_slot.todos) }} +{% else %} - + + + -{% for todo in dep_todos %} +{% endif %} +{% endfor %} +{% if additional_deps %} + +{{ draw_deps(additional_deps) }} +{% endif %} +
expected:
adoptedefforttitlecomments[ ] +{% if dep_slot.task.deps %}
+({{dep_slot.task.title.then}}) +{% for task in dep_slot.task.deps %} +{{ task_with_deps(task, 1) }} +{% endfor %} +
+{% else %} +({{dep_slot.task.title.then}}) +{% endif %} +
bonus:
+
suggestions +{% if todo.task.deps %} + +{% for dep in todo.task.deps %} + + + + + +{% for suggested_todo in suggested_todos[dep.id_] %} - - - - + + + + {% endfor %} +{% endfor %}
make new{{dep.title.then}}
{{ '{:2.1f}'.format(todo.all_days_effort) }} {% if todo.done %}✓{% else %} {% endif %}{{todo.day.date}} {{todo.title}}{{todo.comment}}adopt{{suggested_todo.day.date}}:{{suggested_todo.title}}{% if suggested_todo.deps %}:+{% endif %}{{suggested_todo.comment}}
{% endif %} -
+
free add make from task:
-
-adopt (from to ):
- +
+adopt:
+ -{% for todo in filtered_todos %} +{% for t in filtered_todos %} + {% endfor %} - -{% for task in filtered_tasks %} +
as chain + +{% for dep in todo.deps_chain %} + + + + + {% endfor %} - +
{{dep.deps_depth}}{% if dep.deps_done %}{{ macros.doneness_string(dep) }}{% endif %}{{ draw_todo(dep) }}