- PSQL server running
- Redis server running
- Python 3.9: https://www.python.org/downloads/release/python-3916/
- GDAL installed: https://gdal.org/download.html
- PROJ installed: https://proj.org/install.html
- postgis installed: https://postgis.net/install/
- Copy
.env_sample
and rename it to.env
- Update the env variables to match your local config
- Copy
my_conf_sample.py
and rename it tomy_conf.py
Install PSQL spatial extension https://docs.djangoproject.com/fr/3.2/ref/contrib/gis/install/postgis/
psql postgres
\c fisheriescape
CREATE USER localuser WITH PASSWORD 'localpassword';
ALTER ROLE localuser SET client_encoding TO 'utf8';
ALTER ROLE localuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE localuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE fisheriescape TO localuser;
ALTER ROLE localuser SUPERUSER;
\q
- Create a virtual environment
at
/fisheriescape
python3.9 -m venv venv
- Activate the virtual environment
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Run the unit tests to make sure everything is setup properly
python manage.py test fisheriescape.test
-
Import test data to your local DB
- Get the fixtures.zip file and unzip it somewhere on your local computer. Write down the folder path
- Load the fixtures
python manage.py loaddata [absolute\path\to\fixtures\folder]\*.json
-
Import Score and Vulnerable Species data to your local DB
- Run the app :
python manage.py runserver
- Navigate to http://127.0.0.1:8000/ and login using the email
[email protected]
. The magic link to login will appear in the terminal where Django is running. - Navigate to http://127.0.0.1:8000/fr/fisheriescape/import/fisheriescape-scores
- Upload Vulnerable Species files
- Navigate to http://127.0.0.1:8000/fr/fisheriescape/import/vulnerable-species-spots
- Upload Scores files
Species and vulnerable species will be created automatically, based on the names present in the files imported
- Run the app :
Before proceeding any further, make sure you have completed the steps outlined above.
Static files are not stored in the git repository, they can be pushed to the static file server using python manage.py findstatic
and downloaded to a machine for local development using python manage.py collectstatic
. If this step is skipped the "you are not using chrome" warning message will show and images will appear broken on the "127.0.0.1:8000/en" page
The first step of customizing the site's configuration is by cloning the .env_sample
file and renaming this copy to .env
. This file is also in the .gitignore.
This file has numerous switches and flags that can be used for customizing the application. The .env_sample
file has a lot of annotation and the configuration
settings should be fairly straight-forward. If you find any of them confusing, please open an issuein the dmapps
repo.
Most types of customizations can be done through the .env
file. However, changes made to which apps are switched on/off or which type of database backend you want to
use must be done in a separate file. To do these types of customization, make a copy of the file called ./dm_apps/default_conf.py
to ./dm_apps/my_conf.py
.
The latter file is in the .gitignore therefore none of the changes made will be recorded to the repo. If the my_conf.py
file is present when the
application boots up, the default_conf.py
file will be ignored and the application will look to the my_conf
file. At this point you would be free
to make any changes you like to the my_conf
.
Important: You should not be making changes to the .env_sample
and/or default_conf.py
unless these are changes that are meant to be
persisted in the repository for all users. For example, if you were working on a new app, you would eventually have to modify the default_conf
.
Apps can be easily connected and disconnected from an instance of the application. To do so, you simply comment / uncomment
the app of interest in the app dictionary: my_conf.APP_DICT
. Each connected app should have a card display on the site's main index page.
- If you are reading this, your contributions and collaborations are welcomed :)
- Please do your work locally and make sure to pull regularly from
origin/master
- When ready to merge your work, please be sure to run the project's unit tests before creating your merge request
- if you are using windows, you can run the suite of test using the following batch file:
run_tests_in_windows.bat
- if you are using windows, you can run the suite of test using the following batch file:
- Please do not create a merge request that has conflicts with the master branch, unless you specifically need help with dealing with any conflicting code.
- in the case of the latter, please be sure to properly assign your merge request and add the appropriate comments
Deploying on a production environment will greatly depend on the chosen environment.
If you choose to go along the path of a VPS, the setup process is pretty much the same as the local environment.
The only differences are :
- No need for a
my_config.py
file - Environment variables set for the production values -> don't forget to specify a restrictive array of ALLOWED_HOST
- You might want to change the global admin email in fixtures.zip/auth_user.json before loading the fixtures
- If you choose a managed DB (preferred option), you can skipp the DB creation part and directly set the DB connexion parameters in the .env file.
⚠️ You still need to grant different privileges to the user and install the PSQL spatial extension.
To run the server, configure your reverse proxy (NGINX or other) to run this command : gunicorn dm_apps.wsgi
Please read gunicorn documentation to see which flags you'd like to add to this command (e.g.: number of concurrent workers)