Skip to content

Commit

Permalink
Merge branch 'source-update' into source-general-infos
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos authored Feb 5, 2024
2 parents 2ba646b + 442ad74 commit 277eb44
Show file tree
Hide file tree
Showing 45 changed files with 819 additions and 156 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ jobs:
cp app.env.dist app.env
docker compose build web
- name: Test migrations
run: |
docker compose run --user root --rm web ./manage.py migrate
- name: Check migrations
run: |
docker compose run --user root --rm web ./manage.py makemigrations --check
- name: Test migrations
run: |
docker compose run --user root --rm web ./manage.py migrate
- name: Verify translation files
run: |
docker compose run --user root --rm web ./manage.py makemessages -a --no-location --no-obsolete
- uses: tj-actions/verify-changed-files@v17
- name: Check initial data
run: |
docker compose run --user root --rm web ./manage.py loaddata project/fixtures/initial.json
- uses: tj-actions/verify-changed-files@v18
id: verify-changed-files
with:
files: |
Expand All @@ -59,7 +63,7 @@ jobs:
run: |
docker compose run --user root --rm web coverage xml
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
flags: backend-unittests
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ flake8:
lint: black isort flake8

deps:
docker compose run --rm web bash -c "pip-compile && pip-compile dev-requirements.in"
docker compose run --rm web bash -c "pip-compile && pip-compile dev-requirements.in"

django:
docker compose run --rm web ./manage.py $(filter-out $@,$(MAKECMDGOALS))
2 changes: 1 addition & 1 deletion conf/nginx.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ server {

client_max_body_size 200M;

location ~ ^/(api|config|static_dj|media|base-layers|env.json) {
location ~ ^/(api|config|static_dj|media|base-layers|debug|__debug__|env.json) {
proxy_pass http://django;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down
6 changes: 3 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ babel==2.12.1
# via
# -r docs/requirements.txt
# sphinx
black==23.12.1
black==24.1.1
# via -r dev-requirements.in
build==0.10.0
# via pip-tools
Expand All @@ -35,13 +35,13 @@ click==8.1.3
# -c requirements.txt
# black
# pip-tools
coverage==7.4.0
coverage==7.4.1
# via -r dev-requirements.in
django==4.2.9
# via
# -c requirements.txt
# django-debug-toolbar
django-debug-toolbar==4.2.0
django-debug-toolbar==4.3.0
# via -r dev-requirements.in
docutils==0.18.1
# via
Expand Down
Binary file added docs/source/_static/images/django/config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/images/django/config2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Welcome to TerraVisu's documentation!

user_manual/user_guide.rst
user_manual/admin_user_guide.rst
user_manual/module_configuration.rst

.. toctree::
:maxdepth: 2
Expand Down
50 changes: 48 additions & 2 deletions docs/source/others/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,59 @@
Changelog
==========

2024.01.2+dev (XXXX-XX-XX)
---------------------------

2024.02.3+dev (XXXX-XX-XX)
---------------------------
**Improvements:**

- Add "In progress" status to source
- Source list endpoint now also return ids of related layer
- Add author to Source

**Documentation:**

- Add configuration dashboard doc

**Bugfix:**

- Admin : Fix widgets form crashing on existing widget-less layers


2024.02.3 (2024-02-02)
---------------------------

**Breaking changes**

- To access new debug panel, you should add 'debug' exception in nginx configuration file.

**Improvements:**

- Split Config dashboard debug entries in another /debug/ panel.


2024.02.2 (2024-02-01)
---------------------------

**Improvements:**

- Switch from django-grappelli to django-admin-interface for config dashboard
- Improve config dashboard


2024.02.1 (2024-02-01)
---------------------------

**New features :**

- Admin interface for widgets configuration (admin)
- Widgets can now have an icon and a title (admin & front)
- Widgets can be limited to a specified bbox (admin & front)
- Option to deactivate search in layers (config & front)

**Bug fixes :**

- Fix build non-split for CSS overrides


2024.01.1 (2024-01-22)
---------------------------
Expand All @@ -25,6 +70,7 @@ Changelog
- Fix piecharts going over legends (front)
- Remove options to display labels on secondary styles (admin)


2024.01.0 (2024-01-12)
---------------------------

Expand Down
2 changes: 2 additions & 0 deletions docs/source/user_manual/admin_user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ Vous arrivez sur une page présentant la liste de toutes les vues déclarées.

.. image :: ../_static/images/admin/admin_vue_liste.png
.. _creer-une-vue:

Créer une vue
-------------

Expand Down
109 changes: 109 additions & 0 deletions docs/source/user_manual/module_configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
========================
Module de configuration
========================

Le chemin d’accès au module de configuration est toujours constitué de l’URL du visualiseur suivis de ``/config``.

--------------------------
Panneau de configuration
--------------------------

.. figure:: ../_static/images/django/config.png
:alt: Panneau de configuration
:align: center

Panneau de configuration

--------------------------
Options de configuration
--------------------------

L'entrée ``Config`` dans le panneau de configuration offre le moyen à l'utilisateur de spécifier finement certains paramètres, activer des outils supplémentaires, personnaliser le thème de l'application, etc.

Constance
----------

.. figure:: ../_static/images/django/config2.png
:alt: Page de configuration
:align: center

Page de configuration

Frontend options
~~~~~~~~~~~~~~~~

Options permettant d'activier ou paramétrer des fonctionnalités supplémentaires dans l'application.

- ``VIEW_ROOT_PATH`` : Chemin de la vue racine de l'application
- Exemple : view
- ``OPENID_SSO_LOGIN_BUTTON_TEXT`` : Texte du bouton de connexion pour OpenID
- Exemple : Connexion CD49
- ``OPENID_DEFAULT_LOGIN_BUTTON_TEXT`` : Texte par défaut du bouton de connexion
- Exemple : Autre utilisateur
- ``MEASURE_CONTROL`` : Option pour activer lecontrôle MapBox des mesures sur la carte
- ``MEASURE_DRAW_STYLES`` : Personnalisation du style pour le contrôle des mesures sur la carte
- Exemple :
- ``SEARCH_IN_LOCATIONS`` : Option pour activer la recherche par lieux sur la carte
- ``SEARCH_IN_LOCATIONS_PROVIDER`` : Fournisseur de recherche par lieu (Nominatim uniquement)
- ``NOMINATIM_URL`` : URL de recherche du service Nominatim (https://nominatim.openstreetmap.org/search.php)
- ``NOMINATIM_USE_VIEWBOX`` : Option 'viewbox' de Nominatim pour filtrer les résultats
- ``NOMINATIM_VIEWBOX_MIN_LAT`` : Latitude minimum pour l'option 'viewbox' de Nominatim
- ``NOMINATIM_VIEWBOX_MIN_LONG`` : Longitude minimum pour l'option 'viewbox' de Nominatim
- ``NOMINATIM_VIEWBOX_MAX_LAT`` : Latitude maximum pour l'option 'viewbox' de Nominatim
- ``NOMINATIM_VIEWBOX_MAX_LONG`` : Longitude maximum pour l'option 'viewbox' de Nominatim

General options
~~~~~~~~~~~~~~~~

- ``INSTANCE_TITLE`` : Titre de l'instance
- Exemple : Observatoire du territoire du Maine-et-Loire

Map BBOX options
~~~~~~~~~~~~~~~~

Ces paramètres permettent de limiter l'étendue de la recherche si les options ``NOMINATIM_VIEWBOX_`` ne sont pas renseignées.

- ``MAP_BBOX_LNG_MIN`` : Longitude minimum de la BBox de la carte
- ``MAP_BBOX_LNG_MAX`` : Longitude maximum de la BBox de la carte
- ``MAP_BBOX_LAT_MIN`` : Latitude minimum de la BBox de la carte
- ``MAP_BBOX_LAT_MAX`` : Latitude maximum de la BBox de la carte

Map Zoom options
~~~~~~~~~~~~~~~~

Ces paramètres permettent de spécifier un niveau minimal et maximal entre lesquels il sera possible de naviguer sur la carte.

- ``MAP_MAX_ZOOM`` : Zoom maximum de la carte
- ``MAP_MIN_ZOOM`` : Zoom minimum de la carte

Map default options
~~~~~~~~~~~~~~~~~~~

Ces paramètres permettent de définir l'emprise spatiale de l'application.
Cette emprise pourra être redéfinie au niveau de chaque vue dans l'outil d'administration (se référer à la section :ref:`Créer une vue <creer-une-vue>`).

- ``MAP_DEFAULT_ZOOM`` : Zoom par défaut de la carte
- ``MAP_DEFAULT_LNG`` : Longitude par défaut du centre de la carte
- ``MAP_DEFAULT_LAT`` : Latitude par défaut du centre de la carte

Mapbox options
~~~~~~~~~~~~~~

La clé Mapbox est obligatoire pour l'affichage des cartes de définition de l'empriqse spatiale dans l'outil d'administration.

- ``MAPBOX_ACCESS_TOKEN`` : Clé Mapbox

Theme Options
~~~~~~~~~~~~~~

Options de personnalisation du thème de l'application.

- ``INSTANCE_LOGO`` : Logo affiché en haut à gauche du menu des vues
- ``INSTANCE_LOGO_FRONTEND_URL`` : URL du logo de l'application
- ``INSTANCE_FAVICON`` : Favicon
- ``INSTANCE_SPLASHSCREEN`` : Logo de démarrage (non fonctionnel)
- ``INSTANCE_CREDITS`` : Crédits de l'instance, s'affiche sur la carte en mode impression
- ``INSTANCE_INFO_CONTENT`` : Contenu de l'onglet 'Informations' de l'application



2 changes: 1 addition & 1 deletion install/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ server {
gzip_min_length 256;
gzip_comp_level 4;
client_max_body_size 100M;
location ~ ^/(api|config|base-layers|env.json) {
location ~ ^/(api|config|debug|base-layers|env.json) {
proxy_pass http://django;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down
2 changes: 1 addition & 1 deletion project/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.01.1
2024.02.3
11 changes: 8 additions & 3 deletions project/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from django.utils.translation import gettext_lazy as _

from project.accounts.models import FunctionalPermission, PermanentAccessToken, User
from project.admin import config_site

admin.site.index_title = f'{config.INSTANCE_TITLE}: {_("Debug panel")}'
admin.site.site_header = f'{config.INSTANCE_TITLE}: {_("Debug panel")}'
admin.site.index_title = _(f"Welcome to {config.INSTANCE_TITLE} debug interface.")

admin.site.site_header = f"{config.INSTANCE_TITLE}"
admin.site.index_title = _("Configuration panel / Debug")
admin.site.register(User)


Expand All @@ -25,9 +28,11 @@ def has_change_permission(self, request, obj=None):
return False


@admin.register(PermanentAccessToken)
class PermanentAccessTokenAdmin(admin.ModelAdmin):
list_display = ("id", "user", "created_at", "updated_at")
list_filter = ("user", "created_at", "updated_at")
search_fields = ("user__email", "token")
readonly_fields = ("token",)


config_site.register(PermanentAccessToken, PermanentAccessTokenAdmin)
2 changes: 1 addition & 1 deletion project/accounts/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class AppConfig(PermissionRegistrationMixin, BaseAppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "project.accounts"
verbose_name = "Accounts"
verbose_name = _("Accounts")

permissions = (
("User", "can_manage_users", _("Is able to create, delete, update users")),
Expand Down
16 changes: 16 additions & 0 deletions project/accounts/migrations/0005_alter_user_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.9 on 2024-02-01 15:18

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("accounts", "0004_permanentaccesstoken"),
]

operations = [
migrations.AlterModelOptions(
name="user",
options={"verbose_name": "User", "verbose_name_plural": "Users"},
),
]
4 changes: 4 additions & 0 deletions project/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def get_jwt_token(self):
payload = JSONWebTokenAuthentication.jwt_create_payload(self)
return JSONWebTokenAuthentication.jwt_encode_payload(payload)

class Meta:
verbose_name = _("User")
verbose_name_plural = _("Users")


class FunctionalPermission(Permission):
original = models.OneToOneField(
Expand Down
12 changes: 12 additions & 0 deletions project/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from constance import config
from django.contrib.admin import AdminSite
from django.utils.translation import gettext as _


class ConfigSite(AdminSite):
site_header = _(f"{config.INSTANCE_TITLE}: {_('Configuration')}")
site_title = _(f"{config.INSTANCE_TITLE}: {_('Configuration')}")
index_title = _(f"Welcome to {config.INSTANCE_TITLE} configuration interface.")


config_site = ConfigSite(name="config_site")
16 changes: 10 additions & 6 deletions project/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ def custom_settings(request):
return {
"OIDC_ENABLED": settings.OIDC_ENABLE_LOGIN,
"INSTANCE_TITLE": config.INSTANCE_TITLE,
"INSTANCE_LOGO": config.INSTANCE_LOGO
if config.INSTANCE_LOGO.startswith("/")
else default_storage.url(config.INSTANCE_LOGO),
"INSTANCE_FAVICON": config.INSTANCE_FAVICON
if config.INSTANCE_FAVICON.startswith("/")
else default_storage.url(config.INSTANCE_FAVICON),
"INSTANCE_LOGO": (
config.INSTANCE_LOGO
if config.INSTANCE_LOGO.startswith("/")
else default_storage.url(config.INSTANCE_LOGO)
),
"INSTANCE_FAVICON": (
config.INSTANCE_FAVICON
if config.INSTANCE_FAVICON.startswith("/")
else default_storage.url(config.INSTANCE_FAVICON)
),
}
Loading

0 comments on commit 277eb44

Please sign in to comment.