- PostgreSQL >= 11 + PostGIS
- Python >= 3.9
- the getting started here: https://github.com/sitn/geoshop-demo
- or the tutorial here: https://camptocamp.github.io/geoshop/
Fork and clone this repository, then:
git submodule init
git submodule update
cp .env.sample .env
cp back/default_settings.py back/settings.py
cp scripts/custom.js back/api/templates/gis/adminadapt .env and back/settings.py to your needs.
Create a geoshop user if not existing yet, set your password according to your env.local:
CREATE ROLE geoshop WITH LOGIN PASSWORD <password>;Then, set up a database:
CREATE DATABASE geoshop OWNER geoshop;
REVOKE ALL ON DATABASE geoshop FROM PUBLIC;Then connect to the geoshop database and create extensions:
CREATE EXTENSION postgis;
CREATE EXTENSION unaccent;
CREATE EXTENSION "uuid-ossp";
CREATE SCHEMA geoshop AUTHORIZATION geoshop;
-- TODO: Only if french is needed
CREATE TEXT SEARCH CONFIGURATION fr (COPY = simple);
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING FOR hword, hword_part, word
WITH unaccent, simple;Then, the best is to backup and restore a production db:
.\scripts\1_fetch_prod_db.ps1Now that the database is ready, you can start backend either with Docker or not.
To ease debug, you can add DEBUG=True to your .env file. Never add this to a container exposed on internet.
Run de docker composition with the following command and type local when asked:
python deploy.pyYou should be able to visit the API at http://localhost:5004 or another port if you changed it.
Run tests:
docker compose exec api python manage.py test apiIf not using docker, additional packages are required:
- GDAL (see instructions below to install it in your venv)
- pip install poetry
The .env should be moved inside the geoshop-back folder.
mv .env geoshop-back
cd geoshop-backThen you can install and activate poetry venv:
poetry install --no-root
Invoke-Expression (poetry env activate)You'll need to add GDAL dll to your PATH if you installed it system wide. You can get the dll path with:
python
from pathlib import Path, PureWindowsPath
from osgeo import gdal
print(PureWindowsPath(gdal.__file__).parent)Otherwise, if you installed it in your venv, configure .env properly.
You should now be able to run migrations:
cd back
python manage.py migrateYour database should be ready, now you can run the backend:
python manage.py runserverTranslations can be generated and static files collected with:
python manage.py compilemessages --locale=fr
python manage.py collectstaticpython manage.py runserverpython manage.py test apiInstall the current LTS version of Nodejs.
Install @angular/cli and typescript globally
npm install -g @angular/cli typescriptInstall the dependances of the frontend
cd front
npm installEdit the settings, the file is /front/copy-config.ps1
Typicall values for dev purposes are:
"apiUrl": "https://sitn.ne.ch/geoshop2_prepub_api",
"mediaUrl": "https://sitn.ne.ch/geoshop2_prepub_media/images",To start the debug of the frontend
npm start- Will run the batch /front/copy-config.ps1
- Will automatically run chrome with insecure flags to allow CORS request
- Chrome browser will be waiting with Geoshop2
Create an env.prod file base on env.sample.
Always:
- Run tests locally on docker
- Deploy prepub and test it with a fake order
- Deploy prod
python deploy.pyAnd choose your instance to be deployed. You must have .env.prepub and .env.prod defined at the root of the project.
More info on bookstack
Go to https://update.angular.io/?v=16.0-17.0 and check there are not manual steps to be done.
Then follow instructions. After upgrading, some packages will need to be upgraded according to angular version you will be using. For instance, if you'll upgrade to version 17, you need to target version 17 for these packages:
ng update @ngrx/store@17 angular-split@17After, you can update other packages:
ng update lodash-es rxjs tslib zone.jsFinally, update those related to OpenLayers:
ng update ol ol-ext ol-geocoder proj4Then all the front-end tests should be done.