Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site multiprotocole + CRUVED - REBASED #374

Merged
merged 37 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
78ee9e5
Merged feat/package-module-alembic
Dec 6, 2022
037a2bd
Merged feat/bib-categorie-site
Dec 9, 2022
f75c9f0
Refonte monitoring phase 1 (#117) : DB création modèle mutiplrotocole…
andriacap Dec 12, 2022
e0e1a05
Refonte monitoring phase 1 : Corrections
amandine-sahl Oct 5, 2023
1969b0e
docs: add documentation for new features (wip)
andriacap Oct 30, 2023
442a10c
Optimize model and serialization + corrections + tests
amandine-sahl Oct 6, 2023
2e7bb1c
Gestion asynchrone des données cartographique au niveau des sous modu…
amandine-sahl Mar 26, 2024
a1ca0c3
Corrections filtre des sites via id_inventor (#326)
amandine-sahl Mar 26, 2024
d37d23e
style(front): apply prettier (#329)
andriacap Mar 26, 2024
03bf48d
Update nomenclature with install and add_module_nomenclature cmd (#333)
amandine-sahl Mar 29, 2024
2fc44db
add missing site object on monitorings modules
TheoLechemia Jun 17, 2024
f6b0981
Feat/config with bib type site (#327)
amandine-sahl Jul 2, 2024
775ea52
Refactorisation et fusion de la gestion des formulaires (#349)
amandine-sahl Jul 23, 2024
093bb80
fix(db): remove out of models column declaration + fix back deletion…
mathieu-roudaut-crea Jul 23, 2024
0908773
Lint
amandine-sahl Jul 23, 2024
4e165a8
Fix/delete from datatable (#335)
amandine-sahl Jul 23, 2024
b8ffe88
Valeur par défaut du formulaire
amandine-sahl Jul 26, 2024
5212ddf
Parents_path params pour popup
amandine-sahl Jul 26, 2024
68469b8
Association groupes de site / modules (#358)
TheoLechemia Jul 26, 2024
91f1f62
Permissions : suppression des objets s'ils n'ont pas d'enfants (#360)
amandine-sahl Jul 26, 2024
c11cf0a
Filtrer sur les modules depuis le gestionnaire des groupes de site
amandine-sahl Jul 26, 2024
25cd1d1
SQL warning + ObservationSchema Media
amandine-sahl Jul 29, 2024
ea9dd63
Post rebase
amandine-sahl Jul 29, 2024
646c0f8
- add __MODULE.TYPES_SITE as a usable variable
TheoLechemia Jul 29, 2024
295b5fd
changelog
TheoLechemia Jul 31, 2024
c17b6d1
bootstrap style and remove test css class + style home page
TheoLechemia Aug 1, 2024
8da0586
Fix gestionnaire de site :Ajouter site depuis groupe de sites (#363)
amandine-sahl Aug 1, 2024
8b2cc0e
add in type site in bib_type_site on install
TheoLechemia Aug 1, 2024
9d9eac8
Fix : synchro synthese
amandine-sahl Aug 1, 2024
693dd6b
Récupération d'id_module si non spécifié dans les post_data
amandine-sahl Aug 1, 2024
ff99722
Rename process_all to process_sql. Remove process_csv (#365)
amandine-sahl Aug 1, 2024
74ea637
Détection des changements sur les formulaires méthode change (#368)
amandine-sahl Sep 13, 2024
a4d4e99
Changelog - cf #306
amandine-sahl Oct 4, 2024
97e2f76
0.8.0 - Changelog + doc review (#366)
camillemonchicourt Sep 13, 2024
275571a
README - Fix typo link
camillemonchicourt Sep 13, 2024
15e5466
Fix filter type site label (#369)
amandine-sahl Oct 4, 2024
3fbe49f
Update changelog 0.8.0
camillemonchicourt Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
uses: psf/black@stable
with:
src: "setup.py ./backend/gn_module_monitoring"

frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- name: Frontend code formatting check (Prettier)
uses: creyD/[email protected]
with:
dry: True
prettier_options: --config frontend/.prettierrc --ignore-path frontend/.prettierignore --check frontend/**/*.ts
run: npm install prettier@~3.1.0 && npm run format:check
working-directory: ./frontend
11 changes: 7 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ on:
- hotfixes
- develop
- workshop
- dev-suivi-eolien
pull_request:
branches:
- master
- hotfixes
- develop
- workshop
- workshop
- dev-suivi-eolien

jobs:
build:
Expand All @@ -23,10 +26,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: "Debian 10"
python-version: "3.7"
postgres-version: 11
postgis-version: 2.5
- name: "Debian 11"
python-version: "3.9"
postgres-version: 13
Expand Down Expand Up @@ -91,6 +90,10 @@ jobs:
-e ..[tests] \
-r requirements-dev.txt
working-directory: ./dependencies/GeoNature/backend
- name: Install monitoring module
run: |
python -m pip install -e .
working-directory: .
- name: Install database
run: |
geonature db upgrade geonature@head -x local-srid=2154
Expand Down
209 changes: 133 additions & 76 deletions README.md

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion backend/gn_module_monitoring/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"""

from flask import Blueprint, current_app
from .command.cmd import commands

from geonature.utils.env import DB
from geonature.core.admin.admin import admin as flask_admin

from gn_module_monitoring.monitoring.admin import BibTypeSiteView
from gn_module_monitoring.command.cmd import commands

blueprint = Blueprint(
"monitorings", __name__, template_folder=current_app.config["MEDIA_FOLDER"] + "/monitorings"
Expand All @@ -14,3 +19,5 @@
blueprint.cli.short_help = "Commandes pour l" "administration du module MONITORINGS"
for cmd in commands:
blueprint.cli.add_command(cmd)

flask_admin.add_view(BibTypeSiteView(DB.session, name="Types de site", category="Monitorings"))
85 changes: 33 additions & 52 deletions backend/gn_module_monitoring/command/cmd.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
import os
from pydoc import cli
import click

from pathlib import Path
from flask.cli import with_appcontext
from sqlalchemy.sql import text
from sqlalchemy.sql import text, select

from geonature.utils.env import DB, BACKEND_DIR
from geonature.utils.env import DB
from geonature.core.gn_synthese.models import TSources
from geonature.core.gn_synthese.utils.process import import_from_table
from geonature.core.gn_commons.models import TModules

from gn_module_monitoring.config.repositories import get_config
from gn_module_monitoring.config.utils import monitoring_module_config_path
from gn_module_monitoring.monitoring.models import TMonitoringModules
from gn_module_monitoring.modules.repositories import get_simple_module

from ..monitoring.models import TMonitoringModules
from ..config.repositories import get_config
from ..config.utils import json_from_file, monitoring_module_config_path
from ..modules.repositories import get_module, get_simple_module

from .utils import (
process_export_csv,
from gn_module_monitoring.command.utils import (
process_available_permissions,
remove_monitoring_module,
add_nomenclature,
available_modules,
installed_modules,
process_sql_files,
)


@click.command("process_all")
@click.command("process_sql")
@click.argument("module_code", type=str, required=False, default="")
@with_appcontext
def cmd_process_all(module_code):
def cmd_process_sql(module_code):
"""
Met à jour les paramètres de configuration pour un module
Fichiers sql synthese et export
"""
# process export csv
process_export_csv(module_code)
if module_code:
modules = [module_code]
else:
modules = [module["module_code"] for module in installed_modules()]


@click.command("process_export_csv")
@click.argument("module_code", type=str, required=False, default="")
@with_appcontext
def cmd_process_export_csv(module_code):
"""
Met à jour les fichiers pour les exports pdf
"""
process_export_csv(module_code)
for module in modules:
# process Synthese
process_sql_files(dir=None, module_code=module, depth=1)
# process Exports
process_sql_files(dir="exports/csv", module_code=module, depth=None, allowed_files=None)


@click.command("install")
Expand Down Expand Up @@ -98,8 +94,10 @@ def cmd_install_monitoring_module(module_code):
except Exception:
pass

# process export csv
process_export_csv(module_code)
# process Synthese
process_sql_files(dir=None, module_code=module_code, depth=1)
# process Exports
process_sql_files(dir=None, module_code=module_code, depth=None, allowed_files=None)

config = get_config(module_code, force=True)

Expand Down Expand Up @@ -141,23 +139,6 @@ def cmd_install_monitoring_module(module_code):
process_available_permissions(module_code, session=DB.session)
DB.session.commit()

#  run specific sql
if (module_config_dir_path / "synthese.sql").exists:
click.secho("Execution du script synthese.sql")
sql_script = module_config_dir_path / "synthese.sql"
try:
DB.engine.execute(
text(
open(sql_script, "r")
.read()
.replace(":'module_code'", "'{}'".format(module_code))
.replace(":module_code", "{}".format(module_code))
).execution_options(autocommit=True)
)
except Exception as e:
print(e)
click.secho("Erreur dans le script synthese.sql", fg="red")

# insert nomenclature
add_nomenclature(module_code)

Expand Down Expand Up @@ -195,14 +176,13 @@ def cmd_process_available_permission_module(module_code):
module_code ([string]): code du sous module

"""

if module_code:
process_available_permissions(module_code, session=DB.session)
DB.session.commit()
return
modules = [module_code]
else:
modules = [module["module_code"] for module in installed_modules()]

for module in installed_modules():
process_available_permissions(module["module_code"], session=DB.session)
for module in modules:
process_available_permissions(module, session=DB.session)
DB.session.commit()


Expand Down Expand Up @@ -238,7 +218,9 @@ def synchronize_synthese(module_code, offset):
Synchronise les données d'un module dans la synthese
"""
click.secho(f"Start synchronize data for module {module_code} ...", fg="green")
module = TModules.query.filter_by(module_code=module_code).one()
module = DB.session.execute(
select(TModules).where(TModules.module_code == module_code)
).scalar_one()
table_name = "v_synthese_{}".format(module_code)
import_from_table(
"gn_monitoring",
Expand All @@ -251,11 +233,10 @@ def synchronize_synthese(module_code, offset):


commands = [
cmd_process_export_csv,
cmd_install_monitoring_module,
cmd_process_available_permission_module,
cmd_remove_monitoring_module_cmd,
cmd_add_module_nomenclature_cli,
cmd_process_all,
cmd_process_sql,
synchronize_synthese,
]
Loading
Loading