Skip to content

Commit

Permalink
fixup! fixup! Add support for categories. This fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
christf committed Sep 19, 2018
1 parent b2ea6ba commit 95ff7e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions todoman/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ def new(ctx, summary, list, todo_properties, read_description, interactive):
for key, value in todo_properties.items():
if value:
logger.debug("property: " + key + " value: " + ','.join(value) + " (" + str(type(value)) + ")" )
if key == "categories":
value = [v for v in value]
setattr(todo, key, value)
todo.summary = ' '.join(summary)

Expand Down
13 changes: 10 additions & 3 deletions todoman/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ def set_field(self, name, value):
self.vtodo.pop(name)
if value:
logger.debug("Setting field %s to %s.", name, value)
self.vtodo.add(name, value)
if name == 'categories':
v = icalendar.prop.vInline(','.join(value))
self.vtodo.add(name, v)
else:
self.vtodo.add(name, value)

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

def add_category(self, uid, category):
try:
self._conn.execute(
'''
INSERT INTO categories (
Expand Down Expand Up @@ -648,6 +651,7 @@ def todos(
due=None,
start=None,
startable=False,
categories=None,
status=(
'NEEDS-ACTION',
'IN-PROCESS',
Expand Down Expand Up @@ -800,7 +804,7 @@ def _todo_from_db(self, row):
todo.status = row['status']
todo.description = row['description']
todo.location = row['location']
todo.categories = []
todo.categories = None
#row['categories']
# TODO: category korrekt befüllen
todo.sequence = row['sequence']
Expand Down Expand Up @@ -959,6 +963,9 @@ def update_cache(self):

self.cache.save_to_disk()

def todos(self, **kwargs):
return self.cache.todos(**kwargs)

def todo(self, id, **kwargs):
return self.cache.todo(id, **kwargs)

Expand Down

0 comments on commit 95ff7e6

Please sign in to comment.