TooPath v3 is an API that let you manage tracks and locations related to a device. This API is protected with JWT authentication and follows the GeoJSON RFC 7946.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
If you only want to run TooPath you can use the available Docker image, after setting up database (see Database section below) you can do:
docker build -t toopath/api .
docker run --name toopath --network toopathnetwork -p 8080:8080 toopath/api
And a working instance of TooPath will be available on port 8080.
Network flag is required to connect this container to database container.
- Install python 3.6.1.
- Install OSGeo4W following the steps in GeoDjango Tutorial (make sure to install the same bit version of python and OSGeo4W.
- Install PyCharm (optional, recommended for Windows users).
- Install virtualenvwrapper-win
via
pip install virtualenvwrapper-win
- Install VirtualBox 5.1.
- Install Vagrant 2.0.1.
- Install virtualenvwrapper via
pip install virtualenvwrapper
. - Install PostgreSQL 9.6.
- Install PostGIS 2.3.
This environment setup can be done via console and also, via PyCharm console (if you have installed this IDE). First of all, create a virtual environment:
mkvirtualenv [virtual_environment_name]
If the virtual environment is not automatically activated, then use:
workon [virtual_environment_name]
Install all the python requirements:
pip install -r requirements.txt
As it is recommended on this settings tutorial, this project has production
and local separate settings. To use the local settings setup your DJANGO_SETTINGS_MODULE environment variable
to TooPath3.settings.local
.
There is a Vagrant file and a Docker file with PostgreSQL and PostGIS installed and configured with local settings.
For those who prefer to use Vagrant, follow this Getting started of Vagrant to create a virtual machine with.
Docker users should build image and run a container using (network flag is required to connect this container to TooPath container):
cd bootstrap
docker build -t toopath/postgres .
docker run --name postgres -p 5432:5432 --network toopathnetwork toopath/postgres
Of course, manual configuration is available, you can create the database with the PostgreSQL and PostGIS versions mentioned above.
Apply all the migrations with:
python manage.py migrate
- Go to File>Settings>Project:"name">Project interpreter>Add local
- Select python.exe from [virtual_environment_name] folder
- Mark Associate this virtual environment with current project
- Configure the settings INSTALLED_APPS and DATABASES following the steps in Configure settings.py
Use python manage.py runserver x.x.x.x:aaaa
where x.x.x.x
is the address and aaaa
is the port. For local example:
python manage.py runserver 127.0.0.1:8080
Once you’ve written tests, run them using the test command of your project’s manage.py utility:
python manage.py test
If you wanna run a concrete test you can do it specifying the package. For example, to run the devices test:
python manage.py test TooPath3.devices.tests
If you wanna run test inside docker:
docker exec -it <api_container_name> python manage.py test
To apply the migrations on the production environment use:
python manage.py migrate --settings=TooPath3.settings.production
To start the API on the production enviroment use:
python manage.py runserver x.x.x.x:aaaa --settings=TooPath3.settings.production
You can also setup the DJANGO_SETTINGS_MODULE environment variable to TooPath3.settings.production
.
- Django REST - framework used.
- Django REST-gis - Geographic add-ons for Django REST.
- Jenkins - Integration tool
- Albert Díaz Benitez - First stable version - AlbertWayne
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MIT License - see the LICENSE.md file for details.