X-Git-Url: https://plomlompom.com/repos/?p=misc;a=blobdiff_plain;f=todo.py;fp=todo.py;h=6cade91bf560fb45b42225631aa5cd9e5a089fee;hp=69cb8f5b71fce23d4bffb676f96d8ddd7a133ba3;hb=bd32647c67dd9a4979a39efaf31bfe63c82c72d0;hpb=520a7a19656bb44f43b405fcd65fc495fac62748 diff --git a/todo.py b/todo.py index 69cb8f5..6cade91 100644 --- a/todo.py +++ b/todo.py @@ -61,6 +61,7 @@ to: """ todo_tmpl = """ +

todo

@@ -70,16 +71,31 @@ todo_tmpl = """ - + + +
day weight
comment
done
day tags
day tags +{% for tag in db.t_tags | sort %} +{% if tag in todo.task.tags %} âœ“{% else %}{% endif %} {{ tag }}
+{% endfor %} +add: +
""" task_tmpl = """ +

task

- + +
title
history
    {% for k,v in task.title_history.items() | sort(attribute='0', reverse=True) %}
  • {{ k }}: {{ v|e }}{% endfor %}
default weight
history
    {% for k,v in task.default_weight_history.items() | sort(attribute='0', reverse=True) %}
  • {{ k }}: {{ v|e }}{% endfor %}
tags
history
    {% for k,v in task.tags_history.items() | sort(attribute='0', reverse=True) %}
  • {{ k }}: {{ v|e }}{% endfor %}
tags +{% for tag in db.t_tags | sort %} + {{ tag }}
+{% endfor %} +add:
+
history
    {% for k,v in task.tags_history.items() | sort(attribute='0', reverse=True) %}
  • {{ k }}: {{ v|e }}{% endfor %}
+
""" @@ -94,17 +110,27 @@ comment:

- + {% for uuid, t in db.tasks.items() | sort(attribute='1.title') %} {% if t.visible and (uuid not in db.selected_day.todos.keys() or db.selected_day.todos[uuid].visible) %} - - - - - +{% if uuid in db.selected_day.todos.keys() %} + + + + + + +{% else %} + + + + + +{% endif %} {% endif %} {% endfor %} @@ -237,16 +263,16 @@ class Task: def tags(self, tags): self._set_with_history(self.tags_history, set(tags)) - @property - def tags_joined(self): - return ';'.join(sorted(list(self.tags))) + # @property + # def tags_joined(self): + # return ';'.join(sorted(list(self.tags))) - @tags_joined.setter - def tags_joined(self, tags_string): - tags = set() - for tag in [tag.strip() for tag in tags_string.split(';') if tag.strip() != '']: - tags.add(tag) - self.tags = tags + # @tags_joined.setter + # def tags_joined(self, tags_string): + # tags = set() + # for tag in [tag.strip() for tag in tags_string.split(';') if tag.strip() != '']: + # tags.add(tag) + # self.tags = tags def to_dict(self): return { @@ -348,16 +374,16 @@ class Todo: def title(self): return self.task.title_at(self.day.date) - @property - def day_tags_joined(self): - return ';'.join(sorted(list(self.day_tags))) + # @property + # def day_tags_joined(self): + # return ';'.join(sorted(list(self.day_tags))) - @day_tags_joined.setter - def day_tags_joined(self, tags_string): - tags = set() - for tag in [tag.strip() for tag in tags_string.split(';') if tag.strip() != '']: - tags.add(tag) - self.day_tags = tags + # @day_tags_joined.setter + # def day_tags_joined(self, tags_string): + # tags = set() + # for tag in [tag.strip() for tag in tags_string.split(';') if tag.strip() != '']: + # tags.add(tag) + # self.day_tags = tags @property def tags(self): @@ -485,25 +511,39 @@ class TodoDB(PlomDB): todo = self.days[selected_date].todos[task_uuid] return Template(form_header_tmpl + todo_tmpl + form_footer).render(db=self, todo=todo, action=self.prefix+'/todo') - def update_todo(self, task_uuid, date, day_weight, done, comment, day_tags_joined): + def update_todo_mini(self, task_uuid, date, day_weight, done): if task_uuid in self.days[date].todos.keys(): todo = self.days[date].todos[task_uuid] else: todo = self.days[date].add_todo(task_uuid) todo.day_weight = float(day_weight) if len(day_weight) > 0 else None todo.done = done + return todo + + def update_todo(self, task_uuid, date, day_weight, done, comment, day_tags_joined, day_tags_checked): + todo = self.update_todo_mini(task_uuid, date, day_weight, done) todo.comment = comment - todo.day_tags_joined = day_tags_joined + day_tags = set() + for tag in [tag.strip() for tag in day_tags_joined.split(';') if tag.strip() != '']: + day_tags.add(tag) + for tag in day_tags_checked: + day_tags.add(tag) + todo.day_tags = day_tags def show_task(self, id_): task = self.tasks[id_] if id_ else self.add_task() return Template(form_header_tmpl + task_tmpl + form_footer).render(db=self, task=task, action=self.prefix+'/task') - def update_task(self, id_, title, default_weight, tags_joined): + def update_task(self, id_, title, default_weight, tags_joined, tags_checked): task = self.tasks[id_] if id_ in self.tasks.keys() else self.add_task(id_) task.title = title task.default_weight = float(default_weight) if len(default_weight) > 0 else None - task.tags_joined = tags_joined + tags = set() + for tag in [tag.strip() for tag in tags_joined.split(';') if tag.strip() != '']: + tags.add(tag) + for tag in tags_checked: + tags.add(tag) + task.tags = tags def show_tasks(self): return Template(form_header_tmpl + tag_filters_tmpl + tasks_tmpl + form_footer).render(db=self, action=self.prefix+'/tasks') @@ -545,12 +585,22 @@ class TodoHandler(PlomHandler): elif parsed_url.path == app_config['prefix'] + '/todo': task_uuid = postvars['task_uuid'][0] date = postvars['date'][0] - db.update_todo(task_uuid, date, postvars['day_weight'][0], 'done' in postvars.keys(), postvars['comment'][0], postvars['day_tags'][0]) + tags_checked = [] + prefix = 'day_tag_' + for k in postvars.keys(): + if k.startswith(prefix): + tags_checked += [k[len(prefix):]] + db.update_todo(task_uuid, date, postvars['day_weight'][0], 'done' in postvars.keys(), postvars['comment'][0], postvars['day_tags_joined'][0], tags_checked) homepage = f'{app_config["prefix"]}/todo?task={task_uuid}&date={date}' elif parsed_url.path == app_config['prefix'] + '/task': id_ = postvars['id'][0] - db.update_task(id_, postvars['title'][0], postvars['default_weight'][0], postvars['tags'][0]) + tags_checked = [] + prefix = 'tag_' + for k in postvars.keys(): + if k.startswith(prefix): + tags_checked += [k[len(prefix):]] + db.update_task(id_, postvars['title'][0], postvars['default_weight'][0], postvars['tags_joined'][0], tags_checked) homepage = f'{app_config["prefix"]}/task?id={id_}' elif parsed_url.path in {app_config['prefix'] + '/tasks', app_config['prefix'] + '/day'}: @@ -592,7 +642,7 @@ class TodoHandler(PlomHandler): for i, uuid in enumerate(postvars['t_uuid']): if uuid in postvars['choose']: done = 'done' in postvars and uuid in postvars['done'] - db.update_todo(uuid, db.selected_date, postvars['day_weight'][i], done, postvars['todo_comment'][i], postvars['day_tags'][i]) + db.update_todo_mini(uuid, db.selected_date, postvars['day_weight'][i], done) if 'day_comment' in postvars.keys(): db.selected_day.comment = postvars['day_comment'][0] data += [('selected_date', db.selected_date)] @@ -628,12 +678,13 @@ class TodoHandler(PlomHandler): t_filter_and = None cookie_db['t_and'] = t_filter_and t_filter_not = params.get('t_not', None) - if t_filter_not is None and 't_not' in cookie_db.keys(): - t_filter_not = cookie_db['t_not'] + if t_filter_not is None: + if 't_not' in cookie_db.keys(): + t_filter_not = cookie_db['t_not'] + else: + t_filter_not = ['deleted'] elif t_filter_not == ['-']: t_filter_not = None - else: - t_filter_not = ['deleted'] cookie_db['t_not'] = t_filter_not if parsed_url.path == app_config['prefix'] + '/day': hide_unchosen_params = params.get('hide_unchosen', [])
taskchoose?done?weightday tagscomment
taskchoose?done?weightedit?day tagscomment
] {{ t.current_title|e }}tags: {% for tag in t.tags | sort %}{{ tag }} {% endfor %}
edit{% for tag in db.selected_day.todos[uuid].day_tags | sort %}{{ tag }} {% endfor %}{{ db.selected_day.todos[uuid].comment|e }} +