Django application to automatically synchronise iCalendar URL's to a CalDAV calendar
Find a file
Kevin Alberts a61948d870
All checks were successful
continuous-integration/drone Build is passing
Update start
2024-01-23 15:22:54 +01:00
davinci Changes and docker config 2024-01-23 15:09:09 +01:00
.drone.yml Changes and docker config 2024-01-23 15:09:09 +01:00
.gitignore Add Google Calendar sync that allows sync from calendars that a user has access to, even if they might not have an iCal available. 2020-11-12 01:20:28 +01:00
Dockerfile Update dockerfile and requirements 2024-01-23 15:20:49 +01:00
manage.py Initial commit 2020-11-11 17:02:11 +01:00
README.md Add Google Calendar sync that allows sync from calendars that a user has access to, even if they might not have an iCal available. 2020-11-12 01:20:28 +01:00
requirements.txt Update dockerfile and requirements 2024-01-23 15:17:59 +01:00
start.sh Update start 2024-01-23 15:22:54 +01:00

DAVinci

DAVinci is a Django application that can keep remote iCalendar files (.ics) or Google Calendars synchronized with a CalDAV calendar. It allows for multiple remote ICS files being synchronized to multiple calendars.

Requirements

  • Python 3.8
  • Django 3.1

Installing

  • Clone the repository
git clone https://git.kurocon.nl/Kurocon/DAVinci.git
cd DAVinci
  • Create a virtualenv
virtualenv -p /usr/bin/python3 venv
source ./davinci/bin/activate
  • Install requirements
pip instal -r requirements.txt
  • Setup local settings
cp davinci/local.py.default davinci/local.py
vim davinci/local.py
<edit local.py for your environment>
  • Run migrations
python manage.py migrate
  • Create admin account
python manage.py createsuperuser

Then either run it locally using python manage.py runserver 0.0.0.0:8000, or deploy it on a webserver, for example using Daphne.

When deploying, be sure to set the STATIC_ROOT setting, run python manage.py collectstatic and serve the static files directory under /static on the web server.

Configuring auto-sync

To enable the synchronisation, please configure the following command to be executed every 10 minutes (to allow update intervals down to 10 minutes). You can run the command less frequently as well, but then the minimum update interval will be limited to that interval.

python manage.py ical_sync

The configuration can be done for example by using cron:

# Run ical sync every minute
*/10 * * * * /path/to/python /path/to/manage.py ical_sync

Or via a SystemD timer:

davinci_ical_syc.service

[Unit]
Description=Synchronises configured DAVinci iCalendars with CalDAV
Wants=davinci_ical_sync.timer

[Service]
Type=oneshot
ExecStart=/path/to/python /path/to/manage.py ical_sync

[Install]
WantedBy=multi-user.target

davinci_ical_syc.service

[Unit]
Description=Run the DAVinci iCal sync service every minute
Requires=davinci_ical_syc.service

[Timer]
Unit=davinci_ical_syc.service
OnBootSec=5min
OnCalendar=*:0/10

[Install]
WantedBy=timers.target

Configuring Google Calendar sync

Google Calendar sync makes use of the Google CalDAV API. Because of this, it requires a valid Google API application which is configured to access this API.

In the Google API console, create a project. Then activate the CalDAV API, and create OAuth 2.0 credentials. Download the credential JSON file and put it in the main directory of this application (same directory as manage.py), name it credentials.json.

If you are asked for the required scopes, add (at least) the following:

  • https://www.googleapis.com/auth/userinfo.email
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.googleapis.com/auth/calendar.events.readonly

Usage

Visit /admin and login with your created admin account to manage the synchronisations.

First, add a CalDAV server. Then, add the CalDAV Calendars that you want to sync to, and lastly, create iCalSync objects for each remote .ics file.

For Google Calendar Sync, first go to "Google Authentication Information" and authorize a Google account. Then, add the gCalSync objects under "Google Calendar Syncs".