Skip to content
Nelson Frank edited this page Mar 20, 2024 · 10 revisions

Environment Setup

Clone the project source code:

% git clone https://github.com/rapidpro/casepro.git

Install Python dependencies:

% cd casepro
% virtualenv env
% . env/bin/activate
% pip install -r pip-freeze.txt

Create the PostgreSQL database (enter password nyaruka when prompted):

% createdb casepro
% createuser casepro -P -E
% psql -c "GRANT ALL PRIVILEGES ON DATABASE casepro to casepro;"
% psql -c "CREATE EXTENSION hstore;"

Link up the development settings file

% cp casepro/settings.py.dev casepro/settings.py

Sync the database adding all the models:

% python manage.py migrate

Create our superuser account. Note that CasePro forces a user's username to be always be the same as their email address, so for simplicity it's best to ensure this is true also for the superuser:

% python manage.py createsuperuser

At this point everything should be good to go, you can start with:

% python manage.py runserver

To run background tasks, you'll also need to start celery workers for the two task queues:

% celery -A  casepro worker -Q celery -B -n casepro.celery --loglevel=INFO
% celery -A casepro worker -Q sync -n casepro.sync --loglevel=INFO

Running Tests

% coverage run --source="." manage.py test --verbosity=2 --noinput
% coverage report -m --include="casepro/*" --omit="*/migrations/*,*/tests.py"

Subdomain Setup

The application uses subdomains to determine which organization a user is currently accessing. For example, if you create an organization with the subdomain testing, you should configure that as an alias for localhost. On a UNIX-like system you would edit /etc/hosts as follows:

127.0.0.1	localhost testing.localhost

Backend Integration

The default development settings file uses a "noop" backend that doesn't actually connect to a RapidPro instance. To connect your development instance to RapidPro instance you will need to change these settings to something like:

SITE_API_HOST = 'http://localhost:8001/'
SITE_BACKEND = 'casepro.backend.rapidpro.RapidProBackend'
Clone this wiki locally