# 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 ```bash git clone https://git.kurocon.nl/Kurocon/DAVinci.git cd DAVinci ``` - Create a virtualenv ```bash virtualenv -p /usr/bin/python3 venv source ./davinci/bin/activate ``` - Install requirements ```bash pip instal -r requirements.txt ``` - Setup local settings ```bash cp davinci/local.py.default davinci/local.py vim davinci/local.py ``` - Run migrations ```bash python manage.py migrate ``` - Create admin account ```bash 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](https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/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. ```bash 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](https://developers.google.com/calendar/caldav/v2/guide). Because of this, it requires a valid Google API application which is configured to access this API. In the [Google API console](https://console.developers.google.com/project), 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".