From: Jelmer Vernooij Date: Wed, 13 Jan 2016 02:33:10 +0000 (+0000) Subject: Add support for per calendar colors. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=00acbb286c4594feeb2c09e6e4267bcb4934b7b4;p=jelmer%2Fcalypso.git Add support for per calendar colors. --- diff --git a/calypso/webdav.py b/calypso/webdav.py index 238067a..4db8575 100644 --- a/calypso/webdav.py +++ b/calypso/webdav.py @@ -563,6 +563,13 @@ class Collection(object): self.scan_dir(False) return self.my_items + def get_color(self): + """Color.""" + try: + return "#%s" % self.metadata.get('collection', 'color') + except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError): + return None + @property def last_modified(self): """Get the last time the collection has been modified. diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py index f9d73d7..e94a5e9 100644 --- a/calypso/xmlutils.py +++ b/calypso/xmlutils.py @@ -48,6 +48,7 @@ NAMESPACES = { "C": "urn:ietf:params:xml:ns:caldav", "A": "urn:ietf:params:xml:ns:carddav", "D": "DAV:", + "E": "http://apple.com/ns/ical/", "CS": "http://calendarserver.org/ns/"} log = logging.getLogger(__name__) @@ -179,6 +180,8 @@ def propfind(path, xml_request, collection, depth, context): element.text = item.etag elif tag == _tag("D", "displayname") and is_collection: element.text = collection.name + elif tag == _tag("E", "calendar-color") and is_collection: + element.text = item.get_color() elif tag == _tag("D", "principal-URL"): # TODO: use a real principal URL, read rfc3744-4.2 for info tag = ET.Element(_tag("D", "href"))