Census events and resources
Find census events and resources near you.
- Events and resources
- Partners can enter event information through forms
- Events are published to Google Calendar
- Export events via CSV
- Integrate with SwORD via CSV export
Instead of re-creating a calendar tool, we're leveraging a fantastic and proven one: Google Calendar.
Census Events creates a publishing workflow around Google Calendar. Currently, the publishing is one-way, from Census Events to Google Calendar.
Setup Google Calendar
Census Events will publish events to Google Calendar. You need to create a Calendar as well as a Service Account, to publish events on your behalf.
Make sure you are logged into Google with your G Suite account (you can also use your personal account if you don't have a G Suite organization).
Create a new Google API Project. Click on "My Project" at the top of the page to create a new project.
Create a Service Account for the project. Don't set any roles, they are not necessary.
Create a (JSON) key for the Service Account and save the JSON file. Treat this file as a secret, please don't commit it to GitHub. This JSON string should be provided to the application as the
GOOGLE_SERVICE_ACCOUNT_INFOenvironment variable. You can edit by hand into a single line or use jq.
$ jq -c . ./google-service-account.json
Enable the Calendar API for the API Project you just created.
Create a Google Calendar and share the calendar with your Service Account's email address. You can find your Service Account's email address in the IAM Admin. Allow the Service Account to "Make changes to events" to your calendar. To access sharing settings, open your Google Calendar settings and then click the calendar you just created from the left navigation under "Settings for my calendars".
Copy the Calendar Id from the settings in Google Calendar and set the environment variable
Create calendar events
The application is configured through environment variables. You may set these
.env at the project root and they will be loaded automatically. Copy
.env as a template.
||The list of hostnames to serve requests from.||N||
||The connection settings for the database in URL form.||N||
||Logging verbosity for django module.||N||
||When true, enable debugging features for development.||N||
||The Google Calendar Id where events will be published.||N||
||JSON string containing your Service Account credentials.||N||
||A secret key to provide cryptographic signing for Django.||Y||
||Set the server TZ to your local timezone.||N||
Thank you for considering a contribution to our project! Follow these instructions to get setup for development. Read over our CONTRIBUTING for more information on how we work.
- Python 3.6
We assume you are installing to a python virtualenv using pipenv.
Check your versions (optional):
$ python --version $ python3 --version $ pip --version $ pipenv --version
ONLY do this in the dos-census-events directory. Ensure you are currenty in the project directory.
Initialize new project virtualenv and enter the environment shell:
$ pipenv --python 3
Enter environment shell.
$ pipenv shell
Documentation resource: https://docs.python-guide.org/dev/virtualenvs/
For development, copy these settings to a
.env file in the project root
DEBUG=1 DATABASE_URL=sqlite:///db.sqlite3 SECRET_KEY=not-a-secret
Install the requirements, initialize database and create a super user:
Install python dependencies.
$ pipenv install --dev
Initialize the database.
$ python manage.py migrate
Create an admin user by following the prompts.
$ python manage.py createsuperuser
(Optional) for development you can load in some initial data.
$ python manage.py loaddata --app census events
Setup CSS file references with Django
$ python manage.py collectstatic
Starting the Django server locally:
$ python manage.py runserver
Quitting the server and exiting the shell:
Quit the server using CONTROL-C
Exiting the shell using CONTROL-D or
Working with database migrations
Anytime you make a change to the models, you should try to run makemigrations to generate a database migration.
$ python manage.py makemigrations census
If any modifications were made to the Event model, you might need to update the initial data sample.
$ python manage.py dumpdata --indent 4 census.Event > census/fixtures/events.json