use properties correctly

This commit is contained in:
Jörn-Michael Miehe 2022-09-04 14:14:22 +00:00
parent 513a577914
commit 559803ac0e

View file

@ -1,6 +1,7 @@
from datetime import datetime, timedelta
from typing import Iterator
import caldav
from fastapi import APIRouter, Depends, HTTPException, status
from .. import caldav_principal
@ -38,17 +39,22 @@ async def get_calendar(
elif len(calendar_names) > 1:
raise HTTPException(status_code=status.HTTP_409_CONFLICT)
principal = await caldav_principal()
principal: caldav.Principal = await caldav_principal()
calendar = principal.calendar(name=calendar_names[0])
events = calendar.date_search(
events = []
search_results = calendar.date_search(
start=datetime.now(),
end=datetime.now() + timedelta(days=365),
expand=True,
)
return list(
str(child.contents['summary'][0].value)
for event in events
for child in event.vobject_instance.contents['vevent']
)
for event in search_results:
for vevent in event.vobject_instance.contents["vevent"]:
events.append(vevent.summary.value)
events.append(vevent.description.value)
events.append(str(vevent.dtstart.value))
events.append(str(vevent.dtend.value))
return events