Add Google Calendar sync that allows sync from calendars that a user has access to, even if they might not have an iCal available.

This commit is contained in:
Kevin Alberts 2020-11-12 01:20:28 +01:00
parent a359d7ae04
commit 11628282cb
Signed by: Kurocon
GPG key ID: BCD496FEBA0C6BC1
23 changed files with 359 additions and 19 deletions

View file

@ -1,5 +1,6 @@
# DAVinci
DAVinci is a Django application that can keep remote iCalendar files (.ics) synchronized with a CalDAV calendar. It allows for multiple remote ICS files being synchronized to multiple calendars.
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
@ -48,8 +49,9 @@ When deploying, be sure to set the `STATIC_ROOT` setting, run `python manage.py
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 minute (to allow update intervals down to 1 minute).
You can run the command every hour as well, but then the minimum update interval will be 1 hour.
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
@ -59,7 +61,7 @@ The configuration can be done for example by using cron:
```
# Run ical sync every minute
* * * * * /path/to/python /path/to/manage.py ical_sync
*/10 * * * * /path/to/python /path/to/manage.py ical_sync
```
Or via a SystemD timer:
@ -89,14 +91,30 @@ Requires=davinci_ical_syc.service
[Timer]
Unit=davinci_ical_syc.service
OnBootSec=5min
OnCalendar=*:0/1
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.
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".