Skip to content
Snippets Groups Projects
Commit 6a268449 authored by magicfelix's avatar magicfelix
Browse files

[DAV] Include timezone in calendar-data

parent 1fdb8bc9
No related branches found
No related tags found
1 merge request!1147Implement read-only CalDAV and CardDAV
......@@ -533,6 +533,9 @@ class ExtendedICal20Feed(feedgenerator.ICal20Feed):
cal, with_meta=with_meta, with_reference_object=with_reference_object, params=params
)
if params is not None and "VTIMEZONE" in params and params["VTIMEZONE"]:
cal.add_missing_timezones()
return cal
def to_ical(self, params: Optional[dict[str, any]] = None):
......
......@@ -81,7 +81,7 @@ class CalDAVProp(ElementHandler):
def pre_handle(self):
calendar_data = self._get_calendar_data(self.parent.parent)
comp_name = self.parent.attrs.get("name")
comp_name = self.parent.attrs.get((None, "name"))
prop = self.attrs.get((None, "name"))
calendar_data.params.setdefault(comp_name, []).append(prop)
......@@ -103,11 +103,18 @@ class CalDAVComp(ElementHandler):
name = "{urn:ietf:params:xml:ns:caldav}comp"
invisible = True
@classmethod
def get_name(cls, attrs):
name = attrs.get((None, "name"))
return f"{cls.name}-{name}"
def pre_handle(self):
if self.attrs.get("name") == "VCALENDAR":
attrs = {"name": "VEVENT"}
vevent = CalDAVComp(self.request, self, attrs)
self.children[CalDAVComp.name] = vevent
if self.attrs.get((None, "name")) == "VCALENDAR":
self.children = {}
self.parent.params["VTIMEZONE"] = False
elif self.attrs.get((None, "name")) == "VTIMEZONE":
self.parent.parent.params["VTIMEZONE"] = True
class CalendarData(ElementHandler):
......@@ -116,10 +123,17 @@ class CalendarData(ElementHandler):
def pre_handle(self):
self.params = {}
attrs = {"name": "VCALENDAR"}
attrs = {(None, "name"): "VCALENDAR"}
vcalendar = CalDAVComp(self.request, self, attrs)
self.children[CalDAVComp.name] = vcalendar
self.params["VTIMEZONE"] = True
for comp_name in ("VTIMEZONE", "VEVENT"):
attrs = {(None, "name"): comp_name}
comp = CalDAVComp(self.request, self, attrs)
vcalendar.children[CalDAVComp.name] = comp
def process_xml(self, base, response):
super().process_xml(base, response)
if not self.invisible:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment