</table>
"""
todo_tmpl = """
+<h3>todo</h3>
<input type="hidden" name="task_uuid" value="{{ todo.task.id_ }}" />
<input type="hidden" name="date" value="{{ todo.day.date }}" />
<table>
<tr><th>day weight</th><td class="input"><input type="number" name="day_weight" step=0.1 size=8 value="{{ todo.day_weight }}" /></td></tr>
<tr><th>comment</th><td class="input"><input type="text" name="comment" value="{{todo.comment|e}}" /></td></tr>
<tr><th>done</th><td class="input"><input type="checkbox" name="done" {% if todo.done %}checked{% endif %}/></td></tr>
-<tr><th>day tags</th><td class="input"><input name="day_tags" type="text" value="{{ todo.day_tags_joined|e }}" ></td></tr>
+<tr><th>day tags</th>
+<td>
+{% for tag in db.t_tags | sort %}
+{% if tag in todo.task.tags %} ✓{% else %}<input type="checkbox" name="day_tag_{{tag|e}}"{% if tag in todo.day_tags %} checked{% endif %}/>{% endif %} {{ tag }}<br />
+{% endfor %}
+add: <input name="day_tags_joined" type="text" value="" >
+</td>
+</tr>
</table>
<input type="submit" value="update" />
"""
task_tmpl = """
+<h3>task</h3>
<input type="hidden" name="id" value="{{ task.id_ }}" />
<table>
<tr><th>title</th><td class="input"><input name="title" type="text" value="{{ task.title|e }}" /><details><summary>history</summary><ul>{% for k,v in task.title_history.items() | sort(attribute='0', reverse=True) %}<li>{{ k }}: {{ v|e }}{% endfor %}</ul></details></td></tr>
<tr><th>default weight</th><td class="input"><input type="number" name="default_weight" value="{{ task.default_weight }}" step=0.1 size=8 required /><details><summary>history</summary><ul>{% for k,v in task.default_weight_history.items() | sort(attribute='0', reverse=True) %}<li>{{ k }}: {{ v|e }}{% endfor %}</ul></details></td></tr>
-<tr><th>tags</th><td class="input"><input name="tags" type="text" value="{{ task.tags_joined|e }}" ><details><summary>history</summary><ul>{% for k,v in task.tags_history.items() | sort(attribute='0', reverse=True) %}<li>{{ k }}: {{ v|e }}{% endfor %}</ul></details></td></tr>
+<tr><th>tags</th>
+<td>
+{% for tag in db.t_tags | sort %}
+<input type="checkbox" name="tag_{{tag|e}}"{% if tag in task.tags %} checked{% endif %}/> {{ tag }}<br />
+{% endfor %}
+add: <input name="tags_joined" type="text" value="" ><br />
+<details><summary>history</summary><ul>{% for k,v in task.tags_history.items() | sort(attribute='0', reverse=True) %}<li>{{ k }}: {{ v|e }}{% endfor %}</ul></details>
+</td></tr>
</table>
<input type="submit" value="update" />
"""
</p>
<table class="alternating">
-<tr><th>task</th><th class="checkbox">choose?</th><th class="checkbox">done?</th><th>weight</th><th>day tags</th><th>comment</th></tr>
+<tr><th>task</th><th class="checkbox">choose?</th><th class="checkbox">done?</th><th>weight</th><th>edit?</th><th>day tags</th><th>comment</th></tr>
{% 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) %}
<tr>
<input name="t_uuid" value="{{ uuid }}" type="hidden" >
<td><details><summary>] <a href="{{db.prefix}}/task?id={{ uuid }}" />{{ t.current_title|e }}</a></summary>tags: {% for tag in t.tags | sort %}<a href="{{db.prefix}}/day?t_and={{tag|e}}">{{ tag }}</a> {% endfor %}</details></td>
-<td class="checkbox"><input name="choose" type="checkbox" value="{{ uuid }}" {% if uuid in db.selected_day.todos.keys() %}checked{% endif %} ></td>
-<td class="checkbox"><input name="done" type="checkbox" value="{{ uuid }}" {% if uuid in db.selected_day.todos.keys() and db.selected_day.todos[uuid].done %}checked{% endif %} ></td>
-<td class="checkbox"><input name="day_weight" type="number" step=0.1 size=8 value="{% if uuid in db.selected_day.todos.keys() and db.selected_day.todos[uuid].day_weight %}{{ db.selected_day.todos[uuid].day_weight }}{% endif %}" placeholder={{ t.current_default_weight }} ></td>
-<td type="input"><input name="day_tags" type="text" value="{% if uuid in db.selected_day.todos.keys() %}{{ db.selected_day.todos[uuid].day_tags_joined|e }}{% endif %}" ></td>
-<td type="input"><input name="todo_comment" type="text" value="{% if uuid in db.selected_day.todos.keys() %}{{ db.selected_day.todos[uuid].comment|e }}{% endif %}" ></td>
+{% if uuid in db.selected_day.todos.keys() %}
+<td class="checkbox"><input name="choose" type="checkbox" value="{{ uuid }}" checked></td>
+<td class="checkbox"><input name="done" type="checkbox" value="{{ uuid }}" {% if db.selected_day.todos[uuid].done %}checked{% endif %}></td>
+<td class="checkbox"><input name="day_weight" type="number" step=0.1 size=8 value="{% if db.selected_day.todos[uuid].day_weight is not none %}{{ db.selected_day.todos[uuid].day_weight }}{% endif %}" placeholder={{ t.current_default_weight }} ></td>
+<td><a href="{{db.prefix}}/todo?task={{uuid}}&date={{ db.selected_date }}">edit</a></td>
+<td>{% for tag in db.selected_day.todos[uuid].day_tags | sort %}<a href="{{db.prefix}}/tags?t_and={{tag|e}}">{{ tag }}</a> {% endfor %}</td>
+<td>{{ db.selected_day.todos[uuid].comment|e }}</td>
+{% else %}
+<td class="checkbox"><input name="choose" type="checkbox" value="{{ uuid }}"</td>
+<td class="checkbox"><input name="done" type="checkbox" value="{{ uuid }}"></td>
+<td class="checkbox"><input name="day_weight" type="number" step=0.1 size=8 placeholder={{ t.current_default_weight }} ></td>
+<td></td>
+<td></td>
+<td></td>
+{% endif %}
</tr>
{% endif %}
{% endfor %}
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 {
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):
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')
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'}:
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)]
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', [])