Add color support

You can change the default color by changing the props (.props file for
the filesystem storage backend).
This commit is contained in:
Jochen Sprickerhof 2013-08-17 12:08:40 +02:00
parent d38c4d1c1d
commit 5f2245c35f
2 changed files with 12 additions and 0 deletions

View File

@ -434,6 +434,14 @@ class Collection(object):
with self.props as props: with self.props as props:
return props.get("D:displayname", self.path.split(os.path.sep)[-1]) return props.get("D:displayname", self.path.split(os.path.sep)[-1])
@property
def color(self):
"""Collection color."""
with self.props as props:
if "A:calendar-color" not in props:
props["A:calendar-color"] = "#5ba209"
return props["A:calendar-color"]
@property @property
def headers(self): def headers(self):
"""Find headers items in collection.""" """Find headers items in collection."""

View File

@ -39,6 +39,7 @@ from . import client, config, ical
NAMESPACES = { NAMESPACES = {
"A": "http://apple.com/ns/ical/",
"C": "urn:ietf:params:xml:ns:caldav", "C": "urn:ietf:params:xml:ns:caldav",
"CR": "urn:ietf:params:xml:ns:carddav", "CR": "urn:ietf:params:xml:ns:carddav",
"D": "DAV:", "D": "DAV:",
@ -217,6 +218,7 @@ def propfind(path, xml_request, collections, user=None):
_tag("D", "displayname"), _tag("D", "displayname"),
_tag("D", "owner"), _tag("D", "owner"),
_tag("D", "getetag"), _tag("D", "getetag"),
_tag("A", "calendar-color"),
_tag("CS", "getctag")] _tag("CS", "getctag")]
# Writing answer # Writing answer
@ -330,6 +332,8 @@ def _propfind_response(path, item, props, user):
item.tag, item.headers, item.timezones) item.tag, item.headers, item.timezones)
elif tag == _tag("D", "displayname"): elif tag == _tag("D", "displayname"):
element.text = item.name element.text = item.name
elif tag == _tag("A", "calendar-color"):
element.text = item.color
else: else:
human_tag = _tag_from_clark(tag) human_tag = _tag_from_clark(tag)
if human_tag in collection_props: if human_tag in collection_props: