🍂 API for volunteer work events 🍂
-
Copy
compose.env.example
tocompose.env
and modify it if needed. -
Run
docker compose up
-
Import geo data
docker exec -it haravajarjestelma-backend python manage.py geo_import --municipalities finland
docker exec -it haravajarjestelma-backend python manage.py geo_import --addresses helsinki
docker exec -it haravajarjestelma-backend python manage.py import_helsinki_contract_zones
The project is now running at localhost:8085
- Run
pip install pip-tools
- Run
pip-compile requirements.in
- Run
pip-compile --upgrade requirements.in
- Run
pip-sync requirements.txt
To setup a database compatible with default database settings:
Create user and database
sudo -u postgres createuser -P -R -S haravajarjestelma # use password `haravajarjestelma`
sudo -u postgres createdb -O haravajarjestelma haravajarjestelma
Create extensions in the database
sudo -u postgres psql haravajarjestelma -c "CREATE EXTENSION postgis;"
Allow user to create test database
sudo -u postgres psql -c "ALTER USER haravajarjestelma CREATEDB;"
Run migrations if needed:
python manage.py migrate
Create superuser if needed:
python manage.py createsuperuser
Import geo data
python manage.py geo_import --municipalities finland
python manage.py geo_import --addresses helsinki
python manage.py import_helsinki_contract_zones
- Set the
DEBUG
environment variable to1
. - Run
python manage.py migrate
- Run
python manage.py runserver 0:8085
The project is now running at localhost:8085
In order to get reminder notifications of upcoming events sent to contractors, ./manage.py send_event_reminder_notifications
needs to be run periodically, preferably daily.
The following settings can be used to configure the application either using environment variables or local_settings.py
:
-
EXCLUDED_CONTRACT_ZONES
: List of names of contract zones that should not be imported. Default[]
.Example env:
EXCLUDED_CONTRACT_ZONES=Itä-Helsingin kartanopihat,Suomenlinna
-
EVENT_MINIMUM_DAYS_BEFORE_START
: Minimum amount of days an event needs to be created in advance before it's start. Default7
. -
EVENT_MAXIMUM_COUNT_PER_CONTRACT_ZONE
: Maximum amount of events there can be on one day per contract zone. Default:3
. -
EVENT_REMINDER_DAYS_IN_ADVANCE
: Number of days event reminders to contractors are sent in advance. Default2
. -
HELSINKI_WFS_BASE_URL
: Base URL of Helsinki WFS API that is used as the source for contract zones. Defaulthttps://kartta.hel.fi/ws/geoserver/avoindata/wfs
.
This project uses
black
,
flake8
and
isort
for code formatting and quality checking. Project follows the basic
black config, without any modifications.
Basic black
commands:
- To let
black
do its magic:black .
- To see which files
black
would change:black --check .
pre-commit
can be used to install and
run all the formatting tools as git hooks automatically before a
commit.
New commit messages must adhere to the Conventional Commits specification, and line length is limited to 72 characters.
When pre-commit
is in use, commitlint
checks new commit messages for the correct format.
OpenAPI 3 definition of the API can be found here.