diff --git a/.env-dev.dist b/.env-dev.dist index 80de9e14cb..9beb328aed 100644 --- a/.env-dev.dist +++ b/.env-dev.dist @@ -1,5 +1,5 @@ ENV=dev -SERVER_NAME=geotrek.local +SERVER_NAME=geotrek.localhost POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_USER=geotrek diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000000..950d51bd16 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,25 @@ +#!/bin/bash + +function dockercompose { + # use docker-compose then fallback to new docker compose + docker-compose "$@" + docker compose "$@" +} + +echo "Check dependency graph and fix requirements" + +dockercompose run -T --rm web bash -c "pip-compile -q && pip-compile requirements-dev.in" + + + +echo "run Flake8..." + +dockercompose run -T --rm web flake8 geotrek +status=$? + +if test $status -eq 1 +then + exit $status +else + echo "Flake8 check is ok..." +fi diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 36e4cb8e7f..27d885ac53 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -30,4 +30,4 @@ jobs: run: | cd docs/ pip install -r ./requirements.txt - make html + make html SPHINXOPTS="-W" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3bb77c4751..c4faca87e8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,12 +7,18 @@ env: DEBIAN_FRONTEND: noninteractive jobs: - flake8: - name: Check code styling - runs-on: ubuntu-18.04 + quality: + name: Checking dependency graph and code quality + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - name: Not evaluated values in migration files + run: | + test $(ls geotrek/*/migrations/*.py | xargs grep -l srid | xargs grep -L SRID | wc -l) -eq 0 + + - name: Set up Python 3.8 uses: actions/setup-python@v4 with: @@ -20,13 +26,28 @@ jobs: - name: Install dependencies run: | - pip3 install --upgrade pip - pip3 install flake8 + pip3 install --upgrade pip wheel setuptools + pip3 install -r requirements-dev.txt -U - - name: Flake8 + - name: Check dependency graph run: | - flake8 geotrek + pip-compile -q + pip-compile -q requirements-dev.in - - name: Not evaluated values in migration files + - name: Verify dependency graph is ok + uses: tj-actions/verify-changed-files@v13 + id: verify-changed-files + with: + files: | + requirements.txt + requirements-dev.txt + + - name: Validating graph + if: steps.verify-changed-files.outputs.files_changed == 'true' run: | - test $(ls geotrek/*/migrations/*.py | xargs grep -l srid | xargs grep -L SRID | wc -l) -eq 0 + echo "Dependency file(s) changed: ${{ steps.verify-changed-files.outputs.changed_files }}" + core.setFailed('Please add your new dependencies in setup.py and/or requirements-dev.in then run pip-compile to add them in requirements. (see docs/contribute/development)') + + - name: Flake8 + run: | + flake8 geotrek diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67a0cf1fc3..12416f4717 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,7 +120,9 @@ jobs: run: | python3 -m pip install --upgrade pip setuptools wheel pip3 wheel --wheel-dir=~/.wheel_dir -r requirements.txt + pip3 wheel --wheel-dir=~/.wheel_dir -r requirements-dev.txt pip3 install --find-links=~/.wheel_dir -r requirements.txt + pip3 install --find-links=~/.wheel_dir -r requirements-dev.txt - name: Create test required directories run: | diff --git a/Dockerfile b/Dockerfile index 66c371f176..f3f2deefed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ENV CUSTOM_SETTINGS_FILE="/opt/geotrek-admin/var/conf/custom.py" WORKDIR /opt/geotrek-admin RUN mkdir -p /opt/geotrek-admin/var/log /opt/geotrek-admin/var/cache - +RUN adduser geotrek --disabled-password && chown geotrek:geotrek -R /opt # Install postgis because raster2pgsl is required by manage.py loaddem RUN apt-get update -qq && apt-get install -y -qq \ unzip \ @@ -42,16 +42,19 @@ RUN apt-get update -qq && apt-get install -y -qq \ apt-get install -y --no-install-recommends postgis && \ apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/* -COPY requirements.txt requirements.txt +USER geotrek RUN python3 -m venv /opt/venv -RUN /opt/venv/bin/pip install -U pip setuptools wheel +RUN /opt/venv/bin/pip install --no-cache-dir -U pip setuptools wheel +COPY requirements.txt requirements.txt RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt -U +COPY requirements-dev.txt requirements-dev.txt +RUN /opt/venv/bin/pip install --no-cache-dir -r requirements-dev.txt -U -COPY geotrek/ geotrek/ -COPY manage.py manage.py -COPY VERSION VERSION -COPY setup.cfg setup.cfg -COPY docker/* /usr/local/bin/ +COPY --chown=geotrek:geotrek geotrek/ geotrek/ +COPY --chown=geotrek:geotrek manage.py manage.py +COPY --chown=geotrek:geotrek VERSION VERSION +COPY --chown=geotrek:geotrek setup.cfg setup.cfg +COPY --chown=geotrek:geotrek docker/* /usr/local/bin/ ENTRYPOINT ["/bin/sh", "-e", "/usr/local/bin/entrypoint.sh"] EXPOSE 8000 diff --git a/Makefile b/Makefile index dc461d21c7..ec47c78abc 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,12 @@ build-no-cache: serve: docker-compose up +deps: + docker-compose run --rm web bash -c "pip-compile -q && pip-compile -q requirements-dev.in" + +flake8: + docker-compose run --rm web flake8 geotrek + messages: docker-compose run --rm web ./manage.py makemessages -a --no-location diff --git a/docs/CONTRIBUTING.rst b/docs/CONTRIBUTING.rst new file mode 100644 index 0000000000..bd53ddc22a --- /dev/null +++ b/docs/CONTRIBUTING.rst @@ -0,0 +1,51 @@ +============ +Contributing +============ + +Conventions +----------- + +* Before contributing, open an issue and discuss about it with community (is it a bug or a feature ? What is the best way to achieve my goal ?) +* Use flake8 +* KISS & DRY as much as possible +* Elegant and generic is good, simple is better +* Separate bug fixes and new features in several pull requests. +* Open a new Pull Request in "Draft" status until tests passed. Use at least 'bug', 'improvement' or 'feature' label. +* Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) +* Features are developed in a branch and merged from Github pull-requests. + + +Definition of done +------------------ + +* ``docs/changelog.rst`` is up-to-date +* An explicit unit-test covers the bugfix or the new feature. +* A frontend test (:path:jstests/nav-\*.js) covers the navigation bug fix or feature +* A JS *Mocha* test (:path:jstests/tests.\*.js) covers the JavaScript bug fix or feature +* Unit-tests total coverage is above or at least equal with previous commits. Patch coverage is 100% on new lines. +* Settings have default value in ``settings/base.py`` +* Installation instructions and documentation are up-to-date + +Check TODO in the source tree: + +:: + + find geotrek | xargs egrep -n -i '(TODO|XXX|temporary|FIXME)' + + +Release +------- + +On master branch: + +* If need be, merge ``translations`` branch managed with https://weblate.makina-corpus.net +* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to remove ``+dev`` suffix and increment version (please use semver rules) +* Run ``dch -r -D RELEASED``, update version in the same way and save +* Commit with message 'Release x.y.z' to merge in ``master`` branch before release +* Add git tag X.Y.Z +* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to add ``+dev`` suffix +* Run ``dch -v +dev --no-force-save-on-release`` and save +* Commit with message 'Back to development' +* Push branch and tag +* Add release on Github (copy-paste ``doc/changelog.rst`` paragraph) +* When creating a new release 'x.y.z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.circleci/config.yml`` file for details) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6e1334d20e..ee4a9d6632 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,15 @@ CHANGELOG - Fix intervention datatable list if one intervention has no target +**Development** + +- New contributing guide (docs/CONTRIBUTING.rst). +- Development dependencies are now split in dedicated file. +- pip-tools and flake8 are now available in developer environment. +- Dependency graph is now checked in CI (see docs/contribute/development to how add a new dependency). +- New git pre-commit hook to check all is alright before commit (see docs/contribute/development). + + 2.95.0 (2023-01-24) ----------------------- @@ -380,7 +389,7 @@ In preparation for HD Views developments (PR #3298) - Upgrade mapentity to 8.2.1 -**/!\ Regression /!\** +**! Regression !** - System permissions on files output by `sync_rando` and `sync_mobile` commands were inadvertently changed to more restricted with no reading allowed by group or other. This may cause trouble if your deployment relies on those permissions. @@ -4169,8 +4178,7 @@ In order to enable those features under construction, add ``experimental = True` :notes: Give related permissions to the managers group in order to allow edition - (``add_flatpage``, ``change_flatpage``, ``delete_flatpage``, - ``add_touristiccontent`` ...). + (``add_flatpage``, ``change_flatpage``, ``delete_flatpage``, ``add_touristiccontent`` ...). 0.27.2 (2010-10-14) @@ -4354,6 +4362,7 @@ Since the map export have changed, empty the cache : * Rework display of lists in detail pages, better factorization * Removed links in logbook list for certain models * Display messages in login page too (useful for redirections) + Support edition of several fields on the same map, via django-leaflet new feature (fixes #53) diff --git a/docs/conf.py b/docs/conf.py index 9262d1bae9..226c845fd4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ import sphinx_rtd_theme # noqa +import datetime # Geotrek documentation build configuration file, created by # sphinx-quickstart on Wed May 15 09:50:19 2013. # @@ -41,7 +42,7 @@ # General information about the project. project = 'Geotrek' -copyright = '2013-2021, Makina Corpus' +copyright = f'2013-{datetime.date.today().year}, Makina Corpus' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index 5df9df6d1b..526a79b8a4 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -18,81 +18,55 @@ Quickstart docker-compose run --rm web ./manage.py createsuperuser docker-compose up -d -Go to http://localhost:8000 +Go to http://geotrek.localhost:8000 -PDF generation might not work unless you add the following entry to ``/etc/hosts`` and use ``geotrek.local:8000`` to access Geotrek. +PDF generation might not work unless you use this domain and is correctly set to SERVER_NAME variable in your .env file. -:: - - 127.0.0.1 localhost geotrek.local +Install git hooks +================= -Contribution guide -================== +* Several git hooks are available to prevent pushing to master branch or launch quality tests before committing. Install them with following commands: -Conventions ------------ +:: -* Use flake8 -* KISS & DRY as much as possible -* Elegant and generic is good, simple is better -* Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) -* Features are developed in a branch and merged from Github pull-requests. A git hook to is available to prevent pushing to master, to enable it, developpers should run the following command from root directory (`Geotrek-admin/`) : `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` + ln -s -f ../../.githooks/pre-push .git/hooks/pre-push + ln -s -f ../../.githooks/pre-commit .git/hooks/pre-commit -Definition of done ------------------- +Adding or upgrade dependencies +============================== -* ``docs/changelog.rst`` is up-to-date -* A unit-test covers the bugfix or the new feature -* A frontend test (:path:jstests/nav-\*.js) covers the navigation bug fix or feature -* A JS *Mocha* test (:path:jstests/tests.\*.js) covers the JavaScript bug fix or feature -* Unit-tests coverage is above or at least equal with previous commits -* Settings have default value in ``settings/base.py`` or ``conf/settings-default.ini`` -* Installation instructions are up-to-date +Consider using pip-tools to manage dependencies. -Check TODO in the source tree: +* add your dependency in setup.py for general dependency, requirements-dev.in for dev dependency, then run : :: - find geotrek | xargs egrep -n -i '(TODO|XXX|temporary|FIXME)' + docker-compose run --rm web pip-compile + docker-compose run --rm web pip-compile requirements-dev.in +or -Release -------- - -On master branch: - -* If need be, merge ``translations`` branch managed with https://weblate.makina-corpus.net -* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to remove ``+dev`` suffix and increment version (please use semver rules) -* Run ``dch -r -D RELEASED``, update version in the same way and save -* Commit with message 'Release x.y.z' to merge in ``master`` branch before release -* Add git tag X.Y.Z -* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to add ``+dev`` suffix -* Run ``dch -v +dev --no-force-save-on-release`` and save -* Commit with message 'Back to development' -* Push branch and tag -* Add release on Github (copy-paste ``doc/changelog.rst`` paragraph) -* When creating a new release 'x.y.z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.circleci/config.yml`` file for details) +:: + make deps -Developement -============ Model modification ------------------- +================== :: - docker-compose run web ./manage.py makemigrations - docker-compose run web ./manage.py migrate + docker-compose run --rm web ./manage.py makemigrations + docker-compose run --rm web ./manage.py migrate .. note :: Add migration file to source control. -Model modification - Definition of Done for new model fields ------------------------------------------------------------- +Definition of Done for new model fields +--------------------------------------- When updating or adding a new field ``my_field`` to a model ``MyModel``, please proceed with the following changes to ensure this field is included in existing functionalities. @@ -147,8 +121,27 @@ This migration should rename the old fields generated by modeltranslation ``my_f (example : ``geotrek/trekking/migrations/0014_auto_20200228_2127.py``) +Check quality +============= + +**Flake8** + +run: + +:: + + docker-compose run --rm web flake8 geotrek + + +or + +:: + + make flake8 + + Run tests ---------- +========= **Django tests :** @@ -202,44 +195,37 @@ Launch tests Pictures of the problem and videos are generated in cypress/videos and cypress/screenshots Setup to run rando synchronization locally ------------------------------------------- +========================================== (sync rando is only relevant for an admin paired with geotrek rando v2) In your django settings you must set the 'url' key of SYNC_RANDO_OPTIONS to use the same domain as defined by SERVER_NAME in your .env. -For instance with SERVER_NAME=geotrek.local (default value) +For instance with SERVER_NAME=geotrek.localhost (default value) -:: +.. code-block :: python - SYNC_RANDO_OPTIONS = { - 'url': 'http://geotrek.local:8000' - } + SYNC_RANDO_OPTIONS = { + 'url': 'http://geotrek.localhost:8000' + } Setup to use screamshotter-related features locally ---------------------------------------------------- +=================================================== -Use the domain defined in SERVER_NAME in your .env to reach your local geotrek admin web instance. By default the address is `http://geotrek.local:8000`. - -Update the `/etc/hosts` on your machine to resolve `geotrek.local` on `127.0.0.1`. - -:: +Use the domain defined in SERVER_NAME in your .env to reach your local geotrek admin web instance. By default the address is `http://geotrek.localhost:8000`. - $ cat /etc/hosts - 127.0.0.1 geotrek.local - 127.0.0.1 localhost Database reset --------------- +============== Data only: :: - docker-compose run web ./manage.py flush + docker-compose run --rm web ./manage.py flush Restore existing Database -------------------------- +========================= Assuming a dump of your database is located in your project directory: @@ -252,13 +238,13 @@ Restore your ``./var/conf/`` project files, and data files into ``./var/media``. Then run a synchronization. Mapentity development ---------------------- +===================== TODO UML diagrams of data model --------------------------- +========================== UML diagrams of Geotrek-admin data models are available in ``docs/data-model`` directory. To regenerate them from PostgreSQL, install postgresql-autodoc and graphviz Ubuntu packages diff --git a/docs/faq.rst b/docs/faq.rst index 01e7d1bbd7..2ed4c9312b 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -121,5 +121,5 @@ the source code is probably the least common action. For example : * Fix bugs or improve layout and apparence (*requires Webmaster skills*) ; * Fix bugs or improve core modules (*requires python/Django skills*). -Join us on the `mailing-list `_! Send an email to ``geotrek-fr+subscribe@googlegroups.com`` +Join us on the `mailing list `_! Send an email to ``geotrek-fr+subscribe@googlegroups.com`` and you will receive an invitation automatically :) diff --git a/docs/index.rst b/docs/index.rst index 206069a832..84c4b614a0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -38,10 +38,16 @@ Welcome to Geotrek's documentation! :caption: Contribute :maxdepth: 2 + CONTRIBUTING + contribute/development contribute/translating contribute/documentation - contribute/development contribute/design + +.. toctree:: + :caption: Others + :maxdepth: 2 + authors changelog diff --git a/docs/install/advanced-configuration.rst b/docs/install/advanced-configuration.rst index b50f017179..ca5dcc6331 100644 --- a/docs/install/advanced-configuration.rst +++ b/docs/install/advanced-configuration.rst @@ -218,7 +218,7 @@ Make sure to run these 3 commands daily to maintain synchronization and update r Display reports with status defined colors -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block :: python @@ -228,7 +228,7 @@ Go to the Admin Site and select colors to display for each status (`/admin/feedb Use timers to receive alerts for your reports -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is possible to enable receiving email alerts for reports that have remained in the same status for too long. For instance, I can create two report statuses "To program" with timer days set to 10 and "Programmed" with timer days set to 0. @@ -278,6 +278,7 @@ add the following code: The following settings are related to sensitive areas: + .. code-block :: python SHOW_SENSITIVE_AREAS_ON_MAP_SCREENSHOT = True @@ -287,9 +288,13 @@ The following settings are related to sensitive areas: # Buffer around treks to intersects sensitive areas SENSITIVE_AREA_INTERSECTION_MARGIN = 500 # meters + +.. notes + # Take care if you change this value after adding data. You should update buffered geometry in sql. ``` UPDATE sensitivity_sensitivearea SET geom_buffered = ST_BUFFER(geom, ); ``` + To take these changes into account, you need to run : :: diff --git a/docs/install/import.rst b/docs/install/import.rst index 8c2ff17388..c5f3a772f9 100644 --- a/docs/install/import.rst +++ b/docs/install/import.rst @@ -205,13 +205,13 @@ If you need to cancel the aggregation of portals, remove param ``m2m_aggregate_f Importing from multiple sources with deletion ----------------- +--------------------------------------------- When importing data for the same model using two (or more) different sources, the ``provider`` field should be used to differenciate between sources, allowing to enable object deletion with ``delete = True`` without causing the last parser to delete objects created by preceeding parsers. In the following example, ``Provider_1Parser`` and ``Provider_2Parser`` will each import their objects, set the ``provider`` field on these objects, and only delete objects that disappeared from their respective source since last parsing. -:: +.. code-block:: python class Provider_1Parser(XXXXParser): delete = True @@ -232,7 +232,7 @@ In the following example, ``Provider_1Parser`` and ``Provider_2Parser`` will eac The following example would cause ``NoProviderParser`` to delete objects from ``Provider_2Parser`` and ``Provider_1Parser``. -:: +.. code-block:: python class Provider_1Parser(XXXXParser): delete = True @@ -311,7 +311,7 @@ A usecase for this is to aggregate data from several Geotrek-admin instance. For example, to import treks from another instance, edit ``/opt/geotrek-admin/var/conf/parsers.py`` file with the following content: -:: +.. code-block:: python class DemoGeotrekTrekParser(BaseGeotrekTrekParser): url = "https://remote-geotrek-admin.net" # replace url with remote instance url @@ -343,7 +343,7 @@ You can add parsers in your custom `parsers.py` file (``/opt/geotrek-admin/var/c import data from files directly in your admin (superusers only). For example, some parsers are not available by default but you can use them adding some lines in your parsers file : -:: +.. code-block:: python from geotrek.trekking.parsers import TrekParser # only without dynamic segmentation (`TREKKING_TOPOLOGY_ENABLED` = False) from geotrek.trekking.parsers import POIParser @@ -830,8 +830,8 @@ when the order is not well managed during topologies' display. -Automatication commands ------------------------ +Automatic commands +------------------ You can set up automatic commands by creating a `cron` file under ``/etc/cron.d/geotrek_command`` that contains: diff --git a/docs/install/installation.rst b/docs/install/installation.rst index cc09cdffd2..57d0e0fefc 100644 --- a/docs/install/installation.rst +++ b/docs/install/installation.rst @@ -184,6 +184,7 @@ Geotrek-admin requires at least PostGIS 2.5. If you installed Geotrek-admin on bionic ubuntu with provided install method, you should update your database : :: + # Firstly, backup your database (see previous section) # install postgresql APT repository # (from https://wiki.postgresql.org/wiki/Apt) diff --git a/docs/install/sensitivity.rst b/docs/install/sensitivity.rst index fc170b1a3b..a6b2dcbe81 100644 --- a/docs/install/sensitivity.rst +++ b/docs/install/sensitivity.rst @@ -29,6 +29,9 @@ The following settings are related to sensitive areas: # Buffer around treks to intersects sensitive areas SENSITIVE_AREA_INTERSECTION_MARGIN = 500 # meters + +.. notes + # Take care if you change this value after adding data. You should update buffered geometry in sql. ``` UPDATE sensitivity_sensitivearea SET geom_buffered = ST_BUFFER(geom, ); ``` diff --git a/docs/usage/configuration-ttw.rst b/docs/usage/configuration-ttw.rst index b625864b8e..88abde1e23 100644 --- a/docs/usage/configuration-ttw.rst +++ b/docs/usage/configuration-ttw.rst @@ -116,9 +116,12 @@ Utilisateurs et droits Une fois un utilisateur créé avec les informations minimales, il est possible de lui octroyer un certain nombre de permissions : - **Actif** : permet de déterminer si l'utilisateur peut se connecter à Geotrek-Admin ou non. - Il est préférable de désactiver un compte lorsqu'un utilisateur n'intervient plus sur Geotrek, plutôt que de le supprimer. + + Il est préférable de désactiver un compte lorsqu'un utilisateur n'intervient plus sur Geotrek, plutôt que de le supprimer. En effet supprimer le compte supprimera également par exemple toutes les entrées dans l'historique de Geotrek associées à ce compte. + - **Statut équipe** : si la case est cochée l'utilisateur pourra accéder à l'interface d'administration de Geotrek-Admin + - **Statut super-utilisateur** : permet d'octroyer toutes les permissions à un utilisateur sans avoir à les définir explicitement Il est possible pour un utilisateur, de lui donner des permissions spécifiques. Celles-ci sont déterminées par type d'objet. diff --git a/docs/usage/editing-objects.rst b/docs/usage/editing-objects.rst index b17f7c07df..45bc24b66a 100644 --- a/docs/usage/editing-objects.rst +++ b/docs/usage/editing-objects.rst @@ -17,7 +17,8 @@ Les objets ponctuels ne sont associés qu'à un seul tronçon, sauf dans le cas Chaque évènement dispose néanmoins d'une géométrie calculée à partir de leur segmentation dynamique pour faciliter leur affichage dans Geotrek ou dans QGIS. Il ne faut néanmoins pas modifier directement ces géométries, elles sont calculées automatiquement quand on modifie l'évènement d'un objet. -.. notes:: +.. notes + Des vues SQL sont disponibles pour accéder aux objets de manière plus lisible et simplifiée (``v_interventions`` par exemple). Snapping - Aimantage - Accrochage diff --git a/docs/usage/qgis.rst b/docs/usage/qgis.rst index 21b1705a50..054c3bfc9c 100644 --- a/docs/usage/qgis.rst +++ b/docs/usage/qgis.rst @@ -1,11 +1,11 @@ -======== +================================ Visualiser les données dans QGIS -======== +================================ .. image :: ../images/qgis/Qgis_projet.png Création de vues SQL pour afficher des couches dans QGIS -========= +======================================================== Des vues SQL ont été créées dans la base de données PostgreSQL de Geotrek-admin dans le but de les afficher dans QGIS ou autre. Ces vues contiennent les informations essentielles que l'on retrouve dans Geotrek-admin au niveau de chaque module. @@ -14,7 +14,7 @@ Ces vues sont consultables en lecture seule dans QGIS sous forme de couche SIG. Les modifications se font directement dans Geotrek-admin pour chaque projet, et elles sont répercutées instantanément dans les vues SQL. Créer une connexion à la base de données PostgreSQL du projet -========= +============================================================= 1. Ouvrir le logiciel QGIS 2. Créer une nouvelle connexion de base de données PostgreSQL @@ -34,10 +34,10 @@ Créer une connexion à la base de données PostgreSQL du projet .. image :: ../images/qgis/Connexion_bdd.png Créer un projet QGIS à partir des vues SQL -========= +========================================== Afficher une vue SQL sous forme de couche --------------- +----------------------------------------- * Dans l'Explorateur > PostgreSQL > Ouvrir la connexion précédemment créé > Schéma public * Ajouter les vues : Clic droit sur l'objet > Ajouter la couche au projet @@ -60,12 +60,12 @@ Afficher une vue SQL sous forme de couche * Parcours outdoor <> `v_outdoor_courses` Afficher un fond de plan OpenStreetMap --------------- +-------------------------------------- * Dans l'Explorateur > XYZ Tiles > OpenStreetMap Créer des groupes de couches --------------- +---------------------------- * Dans le panneau des couches > clic droit > Ajouter un groupe @@ -74,14 +74,14 @@ Il peut être utile de créer des groupes de couches dans le cas où certaines c .. image :: ../images/qgis/groupe_couches.png Changer le style d'une couche --------------- +----------------------------- * Clic droit sur la couche > Propriétés > Symbologie Selon le type géométrique de la couche (point, ligne, polygone), il est possible de changer à volonté la couleur de remplissage, la couleur de contour, la taille ou l'épaisseur. Dimensionner les colonnes de la table attributaire --------------- +-------------------------------------------------- Le fait de dimensionner la taille des colonnes dans la table attributaire permet une permet lisibilité des noms de champs et des informations contenues à l'intérieur : @@ -91,12 +91,12 @@ Certains champs texte peuvent être très larges (exemple _Description_ dans la * Clic droit sur la couche > Ouvrir la Table d'Attributs > clic droit sur la colonne > Largeur > Entrer une largeur de colonne (exemple : 200) Afficher le décompte des entités d'une couche --------------- +--------------------------------------------- * Clic droit sur la couche > Afficher le nombre d'entités Zoomer sur l'emprise d'une couche --------------- +--------------------------------- * Clic droit sur la couche > Zoomer sur la(les) couche(s) diff --git a/requirements-dev.in b/requirements-dev.in new file mode 100644 index 0000000000..7b8fc7ddc4 --- /dev/null +++ b/requirements-dev.in @@ -0,0 +1,9 @@ +-c requirements.txt + +pip-tools +flake8 +freezegun +coverage +factory_boy +django-extensions +django-debug-toolbar \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000000..67c7545b57 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,80 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile requirements-dev.in +# +asgiref==3.6.0 + # via + # -c requirements.txt + # django +build==0.10.0 + # via pip-tools +click==8.1.3 + # via + # -c requirements.txt + # pip-tools +coverage==6.5.0 + # via -r requirements-dev.in +django==3.2.16 + # via + # -c requirements.txt + # django-debug-toolbar + # django-extensions +django-debug-toolbar==3.8.1 + # via -r requirements-dev.in +django-extensions==3.2.1 + # via -r requirements-dev.in +factory-boy==3.2.1 + # via -r requirements-dev.in +faker==16.6.1 + # via factory-boy +flake8==6.0.0 + # via -r requirements-dev.in +freezegun==1.2.2 + # via -r requirements-dev.in +mccabe==0.7.0 + # via flake8 +packaging==21.3 + # via + # -c requirements.txt + # build +pip-tools==6.12.1 + # via -r requirements-dev.in +pycodestyle==2.10.0 + # via flake8 +pyflakes==3.0.1 + # via flake8 +pyparsing==3.0.8 + # via + # -c requirements.txt + # packaging +pyproject-hooks==1.0.0 + # via build +python-dateutil==2.8.2 + # via + # faker + # freezegun +pytz==2022.1 + # via + # -c requirements.txt + # django +six==1.16.0 + # via + # -c requirements.txt + # python-dateutil +sqlparse==0.4.2 + # via + # -c requirements.txt + # django + # django-debug-toolbar +tomli==2.0.1 + # via + # build + # pyproject-hooks +wheel==0.38.4 + # via pip-tools + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools diff --git a/requirements.txt b/requirements.txt index 6ce4b52cad..b038a39be8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -70,8 +70,6 @@ coreschema==0.0.4 # via # coreapi # drf-yasg -coverage==6.5.0 - # via geotrek (setup.py) cssselect2==0.7.0 # via # cairosvg @@ -87,9 +85,7 @@ django==3.2.16 # django-appconf # django-appypod # django-clearcache - # django-debug-toolbar # django-embed-video - # django-extensions # django-filter # django-js-asset # django-leaflet @@ -115,16 +111,12 @@ django-compressor==3.1 # via mapentity django-crispy-forms==1.13.0 # via mapentity -django-debug-toolbar==3.8.1 - # via geotrek (setup.py) django-embed-video==1.4.8 # via # mapentity # paperclip django-extended-choices==1.3.3 # via geotrek (setup.py) -django-extensions==3.2.1 - # via geotrek (setup.py) django-filter==22.1 # via mapentity django-js-asset==2.0.0 @@ -168,16 +160,10 @@ easy-thumbnails==2.7 # paperclip env-file==2020.12.3 # via geotrek (setup.py) -factory-boy==3.2.1 - # via geotrek (setup.py) -faker==13.3.4 - # via factory-boy fiona==1.8.21 # via # geotrek (setup.py) # mapentity -freezegun==1.2.2 - # via geotrek (setup.py) geojson==2.5.0 # via # geotrek (setup.py) @@ -190,7 +176,7 @@ html5lib==1.1 # via weasyprint idna==3.4 # via requests -importlib-metadata==5.1.0 +importlib-metadata==6.0.0 # via markdown inflection==0.5.1 # via drf-yasg @@ -256,10 +242,6 @@ pypdf2==1.27.5 # via pdfimpose pyphen==0.11.0 # via weasyprint -python-dateutil==2.8.2 - # via - # faker - # freezegun pytz==2022.1 # via # celery @@ -297,14 +279,11 @@ six==1.16.0 # html5lib # munch # pymemcache - # python-dateutil # zodb soupsieve==2.3.2 # via beautifulsoup4 sqlparse==0.4.2 - # via - # django - # django-debug-toolbar + # via django tif2geojson==0.1.3 # via geotrek (setup.py) tinycss2==1.2.1 @@ -351,7 +330,7 @@ zc-lockfile==2.0 # via zodb zconfig==3.6.1 # via zodb -zipp==3.6.0 +zipp==3.11.0 # via importlib-metadata zodb==5.7.0 # via appy diff --git a/setup.py b/setup.py index b54570add5..9fc1165a5e 100644 --- a/setup.py +++ b/setup.py @@ -67,13 +67,6 @@ def run(self): # prod, 'gunicorn', 'sentry-sdk', - # tests - 'freezegun', - 'coverage', - 'factory_boy', - # dev, - 'django-extensions', - 'django-debug-toolbar', ], cmdclass={"build": BuildCommand}, include_package_data=True,