City of Helsinki ground rent system
-
Run
docker-compose up
-
Run migrations if needed:
docker exec mvj python manage.py migrate
-
Create superuser if needed:
docker exec -it mvj python manage.py createsuperuser
The project is now running at localhost:8000
If you have a Tunnistamo and an mvj-ui instance running with docker in separate docker-compose environments, you can set up a network to sync mvj, mvj-ui and tunnistamo together.
-
Add network definition to tunnistamo's
docker-compose
:version: '3' services: postgres: ... networks: - net django: ... networks: - net networks: net: driver: bridge
-
Connect mvj to tunnistamo's network, by adding this to mvj's and mvj-ui's
docker-compose
:networks: default: external: name: tunnistamo_net
The name
tunnistamo_net
comes from the name of the folder, where tunnistamo lives combined with the name of the network. Change those according to your setup, if needed. -
Now you can access tunnistamo from other docker containers with
tunnistamo-backend
, i.e. Tunnistamo'sdjango
container's name. Connect mvj's OIDC logic to that like so:OIDC_API_TOKEN_AUTH = { ... 'ISSUER': 'http://tunnistamo-backend:8001/openid', ... }
-
Add
tunnistamo-backend
to your computer's localhost aliases. To do this on UNIX-like systems open/etc/hosts
and add it:127.0.0.1 localhost tunnistamo-backend
This way callbacks to
tunnistamo-backend
URL will work locally. -
Configure OIDC settings in Tunnistamo's admin panel. Might require help from other devs.
-
Configure some social auth application to allow requests from your local tunnistamo by using this URL in the settings
http://tunnistamo-backend
Install PostgreSQL and PostGIS.
# Ubuntu 16.04
sudo apt-get install python3-dev libpq-dev postgresql postgis
# Ubuntu 16.04
sudo apt-get install binutils libproj-dev gdal-bin
Create a Python 3.x virtualenv either using the venv
tool or using
the great virtualenvwrapper toolset. Assuming the latter,
once installed, simply do:
mkvirtualenv -p /usr/bin/python3 mvj
The virtualenv will automatically activate. To activate it in the future, just do:
workon mvj
- Run
pip install pip-tools
- Run
pip-compile requirements.in
- Run
pip-compile requirements-dev.in
- Run
pip-compile --upgrade requirements.in
- Run
pip-compile --upgrade requirements-dev.in
- Run
pip install -r requirements.txt
- For development also run
pip install -r requirements-dev.txt
To setup a database compatible with the default database settings:
Create user and database
sudo -u postgres createuser -P -R -S mvj # use password `mvj`
sudo -u postgres createdb -O mvj mvj
Enable PostGIS
sudo -u postgres psql -d "mvj" -c "CREATE EXTENSION IF NOT EXISTS postgis;"
Allow the mvj user to create databases when running tests
sudo -u postgres psql -d "mvj" -c "ALTER USER mvj CREATEDB;"
Tests also require that PostGIS extension is installed on the test database. This can be achieved the easiest by adding PostGIS extension to the default template which is then used when the test databases are created:
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS postgis;"
Environment variables are used to customize configuration in mvj/settings.py
. If you wish to override any
settings, you can place them in a local .env
file which will automatically be sourced when Django imports
the settings file.
Alternatively you can create a local_settings.py
which is executed at the end of the mvj/settings.py
in the
same context so that the variables defined in the settings are available.
The "idc_attachments"-folder under the media root must be excluded when serving media files. The files are protected by permission checks on a different URL.
- Enable debug
echo 'DEBUG=True' >> .env
- Run
python manage.py migrate
- Run
python manage.py loaddata */fixtures/*.json
- Run
python manage.py runserver 0.0.0.0:8000
- Run
pytest
- Run
python manage.py app_makemessages
There are multiple management commands that are required to run. Either when first installing the software or regularly.
Sets permitted groups for each report type.
Sets the default model specific permissions (view, add, change, delete) to the pre-defined groups for the leasing models.
Sets field specific permissions (view, change) to the pre-defined groups.
Sets the default mappings for AD groups to user groups.
Creates invoices for rents that are due in the next month.
Should be run on the first day of every month
Sends unsent invoices to Laske SAP for invoicing.
Should be run every night
Imports index from stat.fi.
Should be run monthly after stat.fi update day
Imports reference interest rates from the Bank of Finland.
Should be run after the Bank of Finland releases new rates
Creates credit notes or invoices if index number has changed after the invoices are sent.
Should be run once a year after the previous years index has been released
Imports leasehold transfers from National Land Survey of Finland (Maanmittauslaitos).
Should be run every week
No need to run.