Merge commit 'refs/merge-requests/6' of gitorious.org:radicale/radicale into merge-requests/6
This commit is contained in:
commit
6c65cc1539
@ -177,6 +177,11 @@ class CalendarHTTPHandler(server.BaseHTTPRequestHandler):
|
|||||||
attributes = posixpath.normpath(self.path.strip("/")).split("/")
|
attributes = posixpath.normpath(self.path.strip("/")).split("/")
|
||||||
if len(attributes) >= 2:
|
if len(attributes) >= 2:
|
||||||
path = "%s/%s" % (attributes[0], attributes[1])
|
path = "%s/%s" % (attributes[0], attributes[1])
|
||||||
|
elif len(attributes) == 1: # no owner
|
||||||
|
path = attributes[0]
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
return ical.Calendar(path)
|
return ical.Calendar(path)
|
||||||
|
|
||||||
def _decode(self, text):
|
def _decode(self, text):
|
||||||
|
@ -56,6 +56,9 @@ def _sha1(hash_value, password):
|
|||||||
|
|
||||||
def has_right(owner, user, password):
|
def has_right(owner, user, password):
|
||||||
"""Check if ``user``/``password`` couple is valid."""
|
"""Check if ``user``/``password`` couple is valid."""
|
||||||
|
if owner is None: # no owner - everybody is allowed
|
||||||
|
return True
|
||||||
|
|
||||||
for line in open(FILENAME).readlines():
|
for line in open(FILENAME).readlines():
|
||||||
if line.strip():
|
if line.strip():
|
||||||
login, hash_value = line.strip().split(":")
|
login, hash_value = line.strip().split(":")
|
||||||
|
@ -135,8 +135,16 @@ class Calendar(object):
|
|||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
"""Initialize the calendar with ``cal`` and ``user`` parameters."""
|
"""Initialize the calendar with ``cal`` and ``user`` parameters."""
|
||||||
|
|
||||||
|
split_path = path.split("/")
|
||||||
|
|
||||||
self.encoding = "utf-8"
|
self.encoding = "utf-8"
|
||||||
self.owner = path.split("/")[0]
|
|
||||||
|
if len(split_path) > 1:
|
||||||
|
self.owner = split_path[0]
|
||||||
|
else:
|
||||||
|
self.owner = None
|
||||||
|
|
||||||
self.path = os.path.join(FOLDER, path.replace("/", os.path.sep))
|
self.path = os.path.join(FOLDER, path.replace("/", os.path.sep))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -51,7 +51,7 @@ def _response(code):
|
|||||||
def name_from_path(path):
|
def name_from_path(path):
|
||||||
"""Return Radicale item name from ``path``."""
|
"""Return Radicale item name from ``path``."""
|
||||||
path_parts = path.strip("/").split("/")
|
path_parts = path.strip("/").split("/")
|
||||||
return path_parts[-1] if len(path_parts) > 2 else None
|
return path_parts[-1] if len(path_parts) >= 2 else None
|
||||||
|
|
||||||
|
|
||||||
def delete(path, calendar):
|
def delete(path, calendar):
|
||||||
@ -129,6 +129,7 @@ def propfind(path, xml_request, calendar, depth):
|
|||||||
tag = ET.Element(_tag("D", "collection"))
|
tag = ET.Element(_tag("D", "collection"))
|
||||||
element.append(tag)
|
element.append(tag)
|
||||||
elif tag == _tag("D", "owner"):
|
elif tag == _tag("D", "owner"):
|
||||||
|
if calendar.owner:
|
||||||
element.text = calendar.owner
|
element.text = calendar.owner
|
||||||
elif tag == _tag("D", "getcontenttype"):
|
elif tag == _tag("D", "getcontenttype"):
|
||||||
element.text = "text/calendar"
|
element.text = "text/calendar"
|
||||||
|
Loading…
Reference in New Issue
Block a user