Skip to content

Commit 95ff7e6

Browse files
committed
fixup! fixup! Add support for categories. This fixes #10
1 parent b2ea6ba commit 95ff7e6

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

todoman/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ def new(ctx, summary, list, todo_properties, read_description, interactive):
371371
for key, value in todo_properties.items():
372372
if value:
373373
logger.debug("property: " + key + " value: " + ','.join(value) + " (" + str(type(value)) + ")" )
374+
if key == "categories":
375+
value = [v for v in value]
374376
setattr(todo, key, value)
375377
todo.summary = ' '.join(summary)
376378

todoman/model.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ def set_field(self, name, value):
299299
self.vtodo.pop(name)
300300
if value:
301301
logger.debug("Setting field %s to %s.", name, value)
302-
self.vtodo.add(name, value)
302+
if name == 'categories':
303+
v = icalendar.prop.vInline(','.join(value))
304+
self.vtodo.add(name, v)
305+
else:
306+
self.vtodo.add(name, value)
303307

304308
def serialize(self, original=None):
305309
"""Serialize a Todo into a VTODO."""
@@ -530,7 +534,6 @@ def add_file(self, list_name, path, mtime):
530534
raise exceptions.AlreadyExists('file', list_name) from e
531535

532536
def add_category(self, uid, category):
533-
try:
534537
self._conn.execute(
535538
'''
536539
INSERT INTO categories (
@@ -648,6 +651,7 @@ def todos(
648651
due=None,
649652
start=None,
650653
startable=False,
654+
categories=None,
651655
status=(
652656
'NEEDS-ACTION',
653657
'IN-PROCESS',
@@ -800,7 +804,7 @@ def _todo_from_db(self, row):
800804
todo.status = row['status']
801805
todo.description = row['description']
802806
todo.location = row['location']
803-
todo.categories = []
807+
todo.categories = None
804808
#row['categories']
805809
# TODO: category korrekt befüllen
806810
todo.sequence = row['sequence']
@@ -959,6 +963,9 @@ def update_cache(self):
959963

960964
self.cache.save_to_disk()
961965

966+
def todos(self, **kwargs):
967+
return self.cache.todos(**kwargs)
968+
962969
def todo(self, id, **kwargs):
963970
return self.cache.todo(id, **kwargs)
964971

0 commit comments

Comments
 (0)