X-Git-Url: https://plomlompom.com/repos/condition_descriptions?a=blobdiff_plain;f=todo.py;h=42639a11c9f28fdfbe34991af191e3bd8dc122ee;hb=472874343c229fc77136e1cc3bae5a1d8bc543f9;hp=88684acff1068a989f103715ba7535a7211d30f0;hpb=5c55641640539a8a2628959d4bbbf3c0a7c8ae19;p=misc
diff --git a/todo.py b/todo.py
index 88684ac..42639a1 100644
--- a/todo.py
+++ b/todo.py
@@ -12,25 +12,28 @@ DATE_FORMAT = '%Y-%m-%d'
html_head = """
tasks: list add | day:
choose tasks
-do tasks
+do tasks
| calendar
"""
@@ -46,8 +49,8 @@ to:
@@ -73,17 +76,17 @@ task_tmpl = """
"""
day_tmpl = """
- hide unchosen |
-prev next |
+ hide unchosen hide done |
+prev next |
-date: |
+date: |
{{ db.selected_day.todos_sum|round(2) }} ({{ db.selected_day.todos_sum2|round(2)}}) |
comment:
@@ -95,9 +98,9 @@ comment:
] {{ t.current_title|e }}tags: {% for tag in t.tags | sort %}{{ tag }} {% endfor %} |
- |
+ |
|
- |
+ |
|
{% endif %}
@@ -149,7 +152,7 @@ tasks_tmpl = """
{% for uuid, t in db.tasks.items() | sort(attribute='1.title') %}
{% if t.visible %}
-{{ t.default_weight }} |
+{{ t.default_weight }} |
{{ t.title|e }} |
{% for tag in t.tags | sort %}{{ tag }} {% endfor %} |
{% endif %}
@@ -344,12 +347,13 @@ class Todo:
class TodoDB(PlomDB):
- def __init__(self, prefix, selected_date=None, t_filter_and = None, t_filter_not = None, hide_unchosen=False):
+ def __init__(self, prefix, selected_date=None, t_filter_and = None, t_filter_not = None, hide_unchosen=False, hide_done=False):
self.prefix = prefix
self.selected_date = selected_date if selected_date else str(datetime.now())[:10]
self.t_filter_and = t_filter_and if t_filter_and else []
self.t_filter_not = t_filter_not if t_filter_not else []
self.hide_unchosen = hide_unchosen
+ self.hide_done = hide_done
self.days = {}
self.tasks = {}
self.t_tags = set()
@@ -363,7 +367,8 @@ class TodoDB(PlomDB):
t = self.add_task(id_=uuid, dict_source=t_dict)
t.visible = len([tag for tag in self.t_filter_and if not tag in t.tags]) == 0\
and len([tag for tag in self.t_filter_not if tag in t.tags]) == 0\
- and ((not self.hide_unchosen) or uuid in self.selected_day.todos)
+ and ((not self.hide_unchosen) or uuid in self.selected_day.todos)\
+ and ((not self.hide_done) or (uuid in self.selected_day.todos and not self.selected_day.todos[uuid].done))
for tag in t.tags:
self.t_tags.add(tag)
@@ -438,7 +443,7 @@ class TodoDB(PlomDB):
days_to_show[current_date] = self.add_day()
else:
days_to_show[current_date] = self.days[current_date]
- days_to_show[current_date].weekday = datetime.strptime(current_date, DATE_FORMAT).strftime('%A')
+ days_to_show[current_date].weekday = datetime.strptime(current_date, DATE_FORMAT).strftime('%A')[:2]
for task_uuid, todo in days_to_show[current_date].todos.items():
todo.visible = self.tasks[task_uuid].visible
return Template(form_header_tmpl + calendar_tmpl + form_footer).render(db=self, days=days_to_show, action=self.prefix+'/calendar', today=str(datetime.now())[:10], start_date=start_date_str, end_date=end_date_str)
@@ -515,7 +520,9 @@ class TodoHandler(PlomHandler):
db.t_filter_not += [target]
if 'hide_unchosen' in postvars.keys():
db.hide_unchosen = True
- data = [('t_and', f) for f in db.t_filter_and] + [('t_not', f) for f in db.t_filter_not] + [('hide_unchosen', int(db.hide_unchosen))]
+ if 'hide_done' in postvars.keys():
+ db.hide_done = True
+ data = [('t_and', f) for f in db.t_filter_and] + [('t_not', f) for f in db.t_filter_not] + [('hide_unchosen', int(db.hide_unchosen))] + [('hide_done', int(db.hide_done))]
if parsed_url.path == prefix + '/tasks':
encoded_params = urlencode(data)
@@ -561,7 +568,9 @@ class TodoHandler(PlomHandler):
t_filter_not = params.get('t_not', ['deleted'])
hide_unchosen_params = params.get('hide_unchosen', [])
hide_unchosen = len(hide_unchosen_params) > 0 and hide_unchosen_params[0] != '0'
- db = TodoDB(prefix, selected_date, t_filter_and, t_filter_not, hide_unchosen)
+ hide_done_params = params.get('hide_done', [])
+ hide_done = len(hide_done_params) > 0 and hide_done_params[0] != '0'
+ db = TodoDB(prefix, selected_date, t_filter_and, t_filter_not, hide_unchosen, hide_done)
if parsed_url.path == prefix + '/day':
page = db.show_day()
elif parsed_url.path == prefix + '/todo':