Development#

Everyone is welcome to contribute to DigiAgriApp, it is possible to work on the server, app or QGIS’s plugin source code, on the documentation or on the website. All the source code are store on GitLab, so a GitLab account is required to contribute to DigiAgriApp.

Everytime you are interested to submit any changes it is required to create a new branch and submit a GitLab Merge Request.

Server source code#

To work on the server source code we suggest to fork the main repository. At this point you can follow the installation procedure, you need to clone your fork instead the main repository.

Running test#

To maintain the consistency of DigiAgriApp there are many tests based on Django’s test suite. All tests are contained into the different Django applications inside tests directory.

First of all you need to create a new PostgreSQL template called template_digiagriapp, it is the same procedure to create a new database and later you need to set it as template, let’s see how to do that. Open a terminal and run

createdb template_digiagriapp
psql -c "CREATE EXTENSION postgis" template_digiagriapp
psql -c "CREATE EXTENSION postgis_raster" template_digiagriapp
psql -c "UPDATE pg_database set datistemplate = 't' where datname = 'template_digiagriapp'" template_digiagriapp

Now enter in DigiAgriApp source code, activate the Python environment and move in src directory. It is possible to execute tests in several ways. You can run tests for a singular test file with, you can replace core.tests.test_models with the path to other files (for example field.tests.test_serializers)

python manage.py test core.tests.test_models

or you can run all the tests for an application (you can replace core with any other application)

python manage.py test core.tests

or you can run all the DigiAgriApp tests with

python manage.py test

It is possible also to use coverage command to run the tests and see how much code is tested with the existing tests. This is really important when you add new functionalities to the DigiAgriApp server. To see the percentage of the tested lines code run

coverage run manage.py test
coverage report -m

The first line will excecute all the tests (this will take a while according to your internet connection speed and your hardware), the second instead will print the percentage of the tested lines for each file.

Test with curl#

curl -H 'Authorization: Token b6398765ae984dd2e07e48f313d0ea2939900008' -d '{"irri_type": 1,"field": [3, 4],"subfield": [13, 14, 15],"row": [10, 17],"active": null,"openings": [-1],"value": 123.0,"unit": 1}' -H "Content-Type: application/json" -X POST https://digiagriapp.lucadelu.org/api/v1/farms/

App#

The app source code is maintained in GitLab and if you want to work on it it is suggested to fork the main repository

Documentation#

This documentation use Sphinx as engine to produce HTML pages and other output formats like PDF. Instead RST is mainly using Markdown to simplify the way to write. The source code is in GitLab.

Website#

The website is written in pure HTML and CSS, you can find the source code in GitLab.