Django Aggregate a Lot of External Content -- CalDav
Aggregate last event from a given CalDav instance.
Plugin of 🤖 dalec.
pip install dalec-caldav
In django settings INSTALLED_APPS
, add:
INSTALLED_APPS = [
...
"dalec",
"dalec_prime",
"dalec_caldav",
...
]
General usage:
{% load dalec %}
{% dalec "caldav" content_type [channel=None] [channel_object=None] [template=None] [ordered_by=None] %}
Retrieves latest updated events of all calendars accessible for the current user:
{% dalec "caldav" "event" %}
Retrieves latest updated events of a calendar defined by an url:
{% dalec "caldav" "event" channel="url" channel_object="https://nextcloud.org/remote.php/dav/public-calendars/<calendarID>" %}
Django settings must define:
DALEC_CALDAV_BASE_URL
: CalDav instance url (ex:https://caldav.org/
)DALEC_CALDAV_API_USERNAME
: CalDav username (ex:admin
)DALEC_CALDAV_API_PASSWORD
: CalDav user password (ex:azeazeaezdfqsmlkrjzr
)
Some other settings are optionnal:
Default to timedelta(days=-1)
. When fetching events from calendar, only events that are newer
from this timedelta will be retrieved. It avoid to retrieve a huge amount of past events.
Default to timedelta(days=365)
. When fetching events from calendar, only events that are older
from this timedelta will be retrieved. It avoid to retrieve a huge amount of past events.
This dalec uses Radicale as tiny python caldav server wich can runs
inside tox out of the box.
If you want to test with other caldavs servers, you can add a local_settings.py
file in
tests/
folder and add a dict conf of extra calendars DALEC_EXTRA_CALDAV_URLS
:
DALEC_EXTRA_CALDAV_URLS = {
"nextclould-v27-public": {
"url": "https://nextcloud.example.com/remote.php/dav/public-calendars/saiGzyBYcWct24W8/",
},
"nextclould-v27-auth": {
"url": "https://nextcloud.example.com/remote.php/dav/calendars/username/calendarname/",
"username": "username",
"password": "secret",
},
"my-other-caldav-events": {
"url": "https://caldav.example.com/xxx/",
},
}
This will perform simple test to check the proxy seems to work with this type of caldav server:
- try to fetch events
- assert there is at least 1 event fetched.
If your calendar has no event, test will fail.