Skip to content

webu/dalec-caldav

Repository files navigation

📅 dalec-caldav

Stable Version Code style: black Imports: isort semver Documentation Status

Django Aggregate a Lot of External Content -- CalDav

Aggregate last event from a given CalDav instance.

Plugin of 🤖 dalec.

Installation

pip install dalec-caldav

In django settings INSTALLED_APPS, add:

INSTALLED_APPS = [
    ...
    "dalec",
    "dalec_prime",
    "dalec_caldav",
    ...
    ]

Usage

General usage:

{% load dalec %}

{% dalec "caldav" content_type [channel=None] [channel_object=None] [template=None] [ordered_by=None] %}

Events

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>" %}

Settings

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:

DALEC_CALDAV_SERCH_EVENT_START_TIMEDELTA

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.

DALEC_CALDAV_SERCH_EVENT_END_TIMEDELTA

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.

Tests

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.