Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
This file contains a brief summary of new features and dependency changes or
releases, in reverse chronological order.

v3.5.0
------
* Fix crashes due to API changes in icalendar 4.0.3.
* Dropped compatibility for icalendar < 4.0.3.

v3.4.1
------
* Support Python 3.7.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'click-log>=0.2.1',
'configobj',
'humanize',
'icalendar',
'icalendar>=4.0.3',
'parsedatetime',
'python-dateutil',
'pyxdg',
Expand Down
5 changes: 4 additions & 1 deletion tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def test_vtodo_serialization(todo_factory):
writer = VtodoWritter(todo)
vtodo = writer.serialize()

assert str(vtodo.get('categories')) == 'tea,drinking,hot'
assert (
[str(c) for c in vtodo.get('categories').cats] ==
['tea', 'drinking', 'hot']
)
assert str(vtodo.get('description')) == description
assert vtodo.get('priority') == 7
assert vtodo.decoded('due') == datetime(3000, 3, 21, tzinfo=tzlocal())
Expand Down
11 changes: 9 additions & 2 deletions todoman/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def serialize_field(self, name, value):
if name in Todo.DATETIME_FIELDS:
return self.normalize_datetime(value)
if name in Todo.LIST_FIELDS:
return ','.join(value)
return value
if name in Todo.INT_FIELDS:
return int(value)
if name in Todo.STRING_FIELDS:
Expand Down Expand Up @@ -537,6 +537,13 @@ def _serialize_rrule(self, todo, field):

return rrule.to_ical().decode()

def _serialize_categories(self, todo, field):
categories = todo.get(field, [])
if not categories:
return ''

return ','.join([str(category) for category in categories.cats])

def add_vtodo(self, todo, file_path, id=None):
"""
Adds a todo into the cache.
Expand Down Expand Up @@ -587,7 +594,7 @@ def add_vtodo(self, todo, file_path, id=None):
todo.get('status', 'NEEDS-ACTION'),
todo.get('description', None),
todo.get('location', None),
todo.get('categories', None),
self._serialize_categories(todo, 'categories'),
todo.get('sequence', 1),
self._serialize_datetime(todo, 'last-modified'),
self._serialize_rrule(todo, 'rrule'),
Expand Down