Merge branch 'master' of github.com:Kozea/Radicale
This commit is contained in:
commit
484933d4b6
2
NEWS.rst
2
NEWS.rst
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
* Clean rights manager based on regular expressions (by Sweil)
|
* Clean rights manager based on regular expressions (by Sweil)
|
||||||
* Support of contacts for Apple's clients
|
* Support of contacts for Apple's clients
|
||||||
|
* Support colors (by Jochen Sprickerhof)
|
||||||
|
* Decode URLs in XML (by Jean-Marc Martins)
|
||||||
|
|
||||||
|
|
||||||
0.8 - Rainbow
|
0.8 - Rainbow
|
||||||
|
@ -27,7 +27,8 @@ Define the main classes of a collection as seen from the server.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
import uuid
|
from uuid import uuid4
|
||||||
|
from random import randint
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ class Item(object):
|
|||||||
self.text = self.text.replace(
|
self.text = self.text.replace(
|
||||||
"\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name)
|
"\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name)
|
||||||
else:
|
else:
|
||||||
self._name = str(uuid.uuid4())
|
self._name = str(uuid4())
|
||||||
self.text = self.text.replace(
|
self.text = self.text.replace(
|
||||||
"\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name)
|
"\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name)
|
||||||
|
|
||||||
@ -437,6 +438,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"] = "#%x" % randint(0, 255 ** 3 - 1)
|
||||||
|
return props["A:calendar-color"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def headers(self):
|
def headers(self):
|
||||||
"""Find headers items in collection."""
|
"""Find headers items in collection."""
|
||||||
|
@ -55,7 +55,7 @@ TYPE = config.get("rights", "type").lower()
|
|||||||
DEFINED_RIGHTS = {
|
DEFINED_RIGHTS = {
|
||||||
"owner_write": "[r]\nuser:.*\ncollection:.*\npermission:r\n"
|
"owner_write": "[r]\nuser:.*\ncollection:.*\npermission:r\n"
|
||||||
"[w]\nuser:.*\ncollection:^%(login)s/.+$\npermission:w",
|
"[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):
|
def _read_from_sections(user, collection, permission):
|
||||||
|
@ -48,6 +48,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:",
|
||||||
@ -226,6 +227,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
|
||||||
@ -340,6 +342,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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user