API backend for Land Availability tool
Make sure you have PostgreSQL (tested with 9.6) installed along with PostGIS extension. You can find more information for the different operating systems here: https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/postgis/
It's strongly suggested to use Postgres.app on OSX and to install all the other tools and dependencies using brew.
createdb landavailability
psql landavailability
> CREATE EXTENSION postgis;
Make sure you have this environment variable set:
SECRET_KEY=<random string>
DATABASE_URL=postgres://USERNAME:PASSWORD@HOST:PORT/DBNAME
example:
SECRET_KEY=abc1234
DATABASE_URL=postgres://andreagrandi@localhost:5432/landavailability
If you are using a Python virtual environment, you can save these values in $venv_folder/bin/postactivate script:
export SECRET_KEY=abc1234
export DATABASE_URL=postgres://andreagrandi@localhost:5432/landavailability
The Land Availability UI needs a user and token. To create these, inside a ./manage.py shell run:
from django.contrib.auth.models import User
from rest_framework.authtoken.models import Token
user = User.objects.create_user('ui')
user.save()
token = Token.objects.create(user=user)
print(token.key)
Run the tests with:
pytest
