- Python 62.5%
- HTML 23.5%
- JavaScript 12%
- CSS 1.9%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| action_sociale | ||
| cadastre | ||
| cats | ||
| db | ||
| ecap | ||
| ecap_intra | ||
| emails_sent | ||
| forest_forpriv | ||
| health | ||
| intranet_proxy | ||
| locale/fr/LC_MESSAGES | ||
| panoview | ||
| parcel_historisation | ||
| ppe | ||
| registre_foncier | ||
| roads | ||
| sitn | ||
| static/images | ||
| stationnement | ||
| .env.sample | ||
| .gitattributes | ||
| .gitignore | ||
| __init__.py | ||
| deploy | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| manage.py | ||
| pylintrc | ||
| README.md | ||
| requirements-lock.txt | ||
| requirements.in | ||
| startup.sh | ||
| wsgi.py | ||
sitn_applications
Apps and custom webservices from SITN. This app can run in two different contexts: internet or intranet. Depending on the context, some apps will not be installed when deploying.
Requirements
- PostgreSQL >= 11 + PostGIS
- Python >= 3.10
- GDAL, GEOS (if running without docker on Windows, install OSGEO4W and add its bin directory to the Path)
- GNU gettext https://www.gnu.org/software/gettext/
Getting started
Fork and clone this repository. Make a copy of the .env.sample file and adapt it to your environment settings:
cp .env.sample .env
and configure the different variables.
The paths related to GDAL et GEOS can either point to existing installations on the system, e.g.:
# Path to the folder containing all GDAL/GEOS DLLs
GDAL_PATH="C:/Program Files/GDAL/"
# Full path to the GDAL DLL
GDAL_LIBRARY_PATH="C:/Program Files/GDAL/gdal.dll"
# Full path to GEOS C API DLL
GEOS_LIBRARY_PATH="C:/Program Files/PostgreSQL/16/bin/libgeos_c.dll"
Alternatively, you can install GDAL (and its GEOS and PROJ dependencies), using the geospatial python wheels provided here:
Download the appropriate version, then install it in the venv using pip, e.g.:
pip install .\gdal-3.11.4-cp314-cp314-win_amd64.whl
Then configure the GDAL paths in the .env file to point to the ressources in the venv, e.g.:
# Path to the folder containing all GDAL/GEOS DLLs
GDAL_PATH="C:/Projects/sitn_applications/venv/Lib/site-packages/osgeo/"
# Full path to the GDAL DLL
GDAL_LIBRARY_PATH="C:/Projects/sitn_applications/venv/Lib/site-packages/osgeo/gdal.dll"
# Full path to GEOS C API DLL
GEOS_LIBRARY_PATH="C:/Projects/sitn_applications/venv/Lib/site-packages/osgeo/geos_c.dll"
You should also have PostgreSQL with PostGIS installed, and the path to PostgreSQL's bin directory should be defined in the Path variable in your Windows system environment variables (e.g. C:\Program Files\PostgreSQL\18\bin).
Finally, you need to have gettext installed:
Running in development mode, without docker
First, create a copy of the .env.sample file called .env:
cp .env.sample .env
Install and activate the virtual environment:
python -m venv venv
./venv/Scripts/activate
python -m pip install --upgrade pip
pip install -r requirements-lock.txt
Create a local database:
python manage.py createdb
Dump some fresh data from prod database
python manage.py getdata
Run migrations
python manage.py migrate
You're now ready to go:
python manage.py collectstatic
python manage.py compilemessages --locale=fr
python manage.py runserver
Switching between the Internet & Intranet instances
If developping on the Internet instance, then you should define a new environment variable
in the .env.dev. file:
IS_INTRANET=False
Running locally on Docker
First, create a copy of the env.sample file called env.<context>.local:
cp .env.sample .env.intranet.local
Then you'll be able to deploy locally on docker:
python deploy intranet local
Deploying on production
Deployments are based on shared .env files. If your project requires migrations, the default user will not be able to create tables, so you must temporarily switch to a more privileged user.
Then you'll be able to deploy your instance with python deploy <context> <instance>
Example:
python deploy intranet prepub
Tests
Running tests will require a database for testing.
python manage.py testdb
then you can run tests
python manage.py test --keepdb
Translations
Prepare translation files
django-admin makemessages -l fr --no-location --ignore venv
then compile them
python manage.py compilemessages --locale=fr
Starting a new app
python manage.py startapp myapp
Then:
- Put something in
urls.pyin your app folder - Import your urls in
sitn/urls.py - Install the app in
settings.py
Upgrading packages
In your venv:
- Update the versions manually in requirements.in if necessary
pip-compile requirements.in --upgrade --output-file=requirements-lock.txtpip install -r requirements-lock.txt