From 5f2245c35fae35fda6cd27c799d3894b487d09e1 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Sat, 17 Aug 2013 12:08:40 +0200 Subject: [PATCH 1/4] Add color support You can change the default color by changing the props (.props file for the filesystem storage backend). --- radicale/ical.py | 8 ++++++++ radicale/xmlutils.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/radicale/ical.py b/radicale/ical.py index e15f4a6..b42f206 100644 --- a/radicale/ical.py +++ b/radicale/ical.py @@ -434,6 +434,14 @@ class Collection(object): with self.props as props: 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 def headers(self): """Find headers items in collection.""" diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index a3d7236..f310d44 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -39,6 +39,7 @@ from . import client, config, ical NAMESPACES = { + "A": "http://apple.com/ns/ical/", "C": "urn:ietf:params:xml:ns:caldav", "CR": "urn:ietf:params:xml:ns:carddav", "D": "DAV:", @@ -217,6 +218,7 @@ def propfind(path, xml_request, collections, user=None): _tag("D", "displayname"), _tag("D", "owner"), _tag("D", "getetag"), + _tag("A", "calendar-color"), _tag("CS", "getctag")] # Writing answer @@ -330,6 +332,8 @@ def _propfind_response(path, item, props, user): item.tag, item.headers, item.timezones) elif tag == _tag("D", "displayname"): element.text = item.name + elif tag == _tag("A", "calendar-color"): + element.text = item.color else: human_tag = _tag_from_clark(tag) if human_tag in collection_props: From 423feaec2aa0cb9f7d407938c5eaf146a1a77ba2 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 27 Aug 2013 17:06:16 +0200 Subject: [PATCH 2/4] Get a random color for calendars with no color --- radicale/ical.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/radicale/ical.py b/radicale/ical.py index 23e4def..6da00a1 100644 --- a/radicale/ical.py +++ b/radicale/ical.py @@ -27,7 +27,8 @@ Define the main classes of a collection as seen from the server. import os import posixpath -import uuid +from uuid import uuid4 +from random import randint from contextlib import contextmanager @@ -102,7 +103,7 @@ class Item(object): self.text = self.text.replace( "\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name) else: - self._name = str(uuid.uuid4()) + self._name = str(uuid4()) self.text = self.text.replace( "\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name) @@ -442,7 +443,7 @@ class Collection(object): """Collection color.""" with self.props as props: if "A:calendar-color" not in props: - props["A:calendar-color"] = "#5ba209" + props["A:calendar-color"] = "#%x" % randint(0, 255 ** 3 - 1) return props["A:calendar-color"] @property From 2a2b80e5fb41fd09c56201311609c66136a73f7a Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 27 Aug 2013 17:08:10 +0200 Subject: [PATCH 3/4] Update news --- NEWS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index f8e6e61..2488135 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -8,6 +8,8 @@ * Clean rights manager based on regular expressions (by Sweil) * Support of contacts for Apple's clients +* Support colors (by Jochen Sprickerhof) +* Decode URLs in XML (by Jean-Marc Martins) 0.8 - Rainbow From 8c3cf6bccd78548121d17880e367843d765ccab4 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Wed, 28 Aug 2013 00:56:45 +0300 Subject: [PATCH 4/4] Fix built-in owner_only right --- radicale/rights.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/rights.py b/radicale/rights.py index d8e3228..232fec2 100644 --- a/radicale/rights.py +++ b/radicale/rights.py @@ -55,7 +55,7 @@ TYPE = config.get("rights", "type").lower() DEFINED_RIGHTS = { "owner_write": "[r]\nuser:.*\ncollection:.*\npermission:r\n" "[w]\nuser:.*\ncollection:^%(login)s/.+$\npermission:w", - "owner_only": "[rw]\nuser:.\ncollection: ^%(login)s/.+$\npermission:rw"} + "owner_only": "[rw]\nuser:.*\ncollection:^%(login)s/.+$\npermission:rw"} def _read_from_sections(user, collection, permission):