Skip to content

Development

Tuomas Airaksinen edited this page Oct 30, 2019 · 4 revisions

Running tests with docker-compose

Run:

docker-compose -f docker-compose-tests.yml run tests

Running staging system with docker-compose

Run:

docker-compose -f docker-compose-staging.yml run upgrade # initialize everything
docker-compose -f docker-compose-staging.yml run upgrade createsuperuser
docker-compose -f docker-compose-staging.yml up -d

then go to http://localhost:8080 and log in.

How to set things up and run your local development environment:

Install dependencies:

sudo apt-get install python-dev python-pip virtualenv libpq-dev\
                     postgresql-server-dev-all virtualenvwrapper

Note: Python 3.6 or newer is required.

Create virtualenv:

mkvirtualenv -p /usr/bin/python3.6 serviceform_env

To start using it type:

workon serviceform_env

Install requirements to your virtualenv:

pip install -r requirements.txt

Run external services (redis and postgresql) inside docker:

docker-compose up

When DB is set up, you can run initial migrations with command:

./manage.py migrate

Then you must create your initial account:

./manage.py createsuperuser

Then run can run development server:

./manage.py runserver

Then open browser in http://localhost:8000 and use your initial superuser account to log in.

Dumping and loading database in development environment

Database can be dumped with the following command:

docker-compose exec -u postgres db pg_dump serviceform > init.sql

To load dump, you must first clear the current database. This can be done as follows:

docker-compose exec -T -u postgres db psql serviceform < init.sql

Dump data in json format for tests:

./manage.py dumpdata -o tests/test_data.json -e serviceform.EmailMessage -e admin.LogEntry --indent 2 -e sessions.Session

Translations

If changes to translatable strings are made, run:

cd serviceform
django-admin.py makemessages

Then update translation (.po) files for example with poedit, and then run:

django-admin.py compilemessages

Then commit your changes (.po and .mo files) to repository.