🍂 API for volunteer work events 🍂
-
Copy
compose.env.exampletocompose.envand modify it if needed. -
Run
docker compose up -
Import geo data
docker exec -it haravajarjestelma-backend python manage.py geo_import --municipalities finlanddocker exec -it haravajarjestelma-backend python manage.py geo_import --addresses helsinkidocker 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
DEBUGenvironment 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:4. -
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 Ruff for code formatting and quality checking.
Basic ruff commands:
- lint:
ruff check - apply safe lint fixes:
ruff check --fix - check formatting:
ruff format --check - format:
ruff format
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.
Project includes a .git-blame-ignore-revs file for ignoring certain commits from git blame.
This can be useful for ignoring e.g. formatting commits, so that it is more clear from git blame
where the actual code change came from. Configure your git to use it for this project with the
following command:
git config blame.ignoreRevsFile .git-blame-ignore-revs