From abfdef0b69930236380913c45657b7497a29b168 Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Fri, 23 Jun 2023 16:34:46 +0200 Subject: [PATCH 1/8] Add table t_meta_taxref --- .../32c5ed42bdbd_add_table_t_meta_taxref.py | 53 +++++++++++++++++++ .../commands/migrate_taxref/commands_v15.py | 8 ++- .../commands/migrate_taxref/commands_v16.py | 8 ++- apptax/taxonomie/commands/taxref.py | 8 ++- apptax/taxonomie/commands/taxref_v15_v16.py | 5 +- apptax/taxonomie/commands/utils.py | 6 +++ apptax/taxonomie/models.py | 8 +++ apptax/taxonomie/routestaxref.py | 13 +++++ apptax/tests/test_taxref.py | 6 +++ apptax/tests/test_taxref_last_version.py | 10 ++-- 10 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py diff --git a/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py b/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py new file mode 100644 index 00000000..60031a6d --- /dev/null +++ b/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py @@ -0,0 +1,53 @@ +"""Add table: t_meta_taxref + +Revision ID: 32c5ed42bdbd +Revises: 3bd542b72955 +Create Date: 2023-06-23 15:51:00.031901 + +""" +import datetime +from alembic import op +from sqlalchemy import Column, Unicode, DateTime, func +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "32c5ed42bdbd" +down_revision = "3bd542b72955" +branch_labels = None +depends_on = None + + +def upgrade(): + op.create_table( + "t_meta_taxref", + Column("taxref_version", Unicode, primary_key=True), + Column("taxref_update_date", DateTime, server_default=func.now()), + schema="taxonomie", + ) + op.execute( + """ + WITH meta_taxref AS ( + SELECT 1019039 as max_cd_nom, 'TAXREF v16' AS taxref_version + UNION + SELECT 1002708 as max_cd_nom, 'TAXREF v15' AS taxref_version + UNION + SELECT 972486 as max_cd_nom, 'TAXREF v14' AS taxref_version + UNION + SELECT 935095 as max_cd_nom, 'TAXREF v13' AS taxref_version + UNION + SELECT 887126 as max_cd_nom, 'TAXREF v11' AS taxref_version + ) + INSERT INTO taxonomie.t_meta_taxref (taxref_version) + SELECT taxref_version + FROM taxonomie.taxref AS t + JOIN meta_taxref m + ON t.cd_nom = max_cd_nom + ORDER BY cd_nom DESC + LIMIT 1; + """ + ) + + +def downgrade(): + op.drop_table(table_name="t_meta_taxref", schema="taxonomie") diff --git a/apptax/taxonomie/commands/migrate_taxref/commands_v15.py b/apptax/taxonomie/commands/migrate_taxref/commands_v15.py index 2da8a52c..04811a2f 100644 --- a/apptax/taxonomie/commands/migrate_taxref/commands_v15.py +++ b/apptax/taxonomie/commands/migrate_taxref/commands_v15.py @@ -9,7 +9,12 @@ from utils_flask_sqla.migrations.utils import open_remote_file from apptax.database import db -from apptax.taxonomie.commands.utils import copy_from_csv, truncate_bdc_statuts, refresh_taxref_vm +from apptax.taxonomie.commands.utils import ( + copy_from_csv, + truncate_bdc_statuts, + refresh_taxref_vm, + insert_taxref_numversion, +) from apptax.taxonomie.commands.taxref_v15_v16 import import_bdc_statuts_v15 from .utils import save_data, analyse_taxref_changes from . import logger @@ -132,6 +137,7 @@ def apply_changes( logger.info("Refresh materialized views…") refresh_taxref_vm() + insert_taxref_numversion("15") db.session.commit() diff --git a/apptax/taxonomie/commands/migrate_taxref/commands_v16.py b/apptax/taxonomie/commands/migrate_taxref/commands_v16.py index f750e225..dbce52e0 100644 --- a/apptax/taxonomie/commands/migrate_taxref/commands_v16.py +++ b/apptax/taxonomie/commands/migrate_taxref/commands_v16.py @@ -9,7 +9,12 @@ from utils_flask_sqla.migrations.utils import open_remote_file from apptax.database import db -from apptax.taxonomie.commands.utils import copy_from_csv, truncate_bdc_statuts, refresh_taxref_vm +from apptax.taxonomie.commands.utils import ( + copy_from_csv, + truncate_bdc_statuts, + refresh_taxref_vm, + insert_taxref_numversion, +) from apptax.taxonomie.commands.taxref_v15_v16 import import_bdc_statuts_v16 from .utils import save_data, analyse_taxref_changes from . import logger @@ -132,6 +137,7 @@ def apply_changes( logger.info("Refresh materialized views…") refresh_taxref_vm() + insert_taxref_numversion("16") db.session.commit() diff --git a/apptax/taxonomie/commands/taxref.py b/apptax/taxonomie/commands/taxref.py index f0966344..08e3df83 100644 --- a/apptax/taxonomie/commands/taxref.py +++ b/apptax/taxonomie/commands/taxref.py @@ -2,7 +2,7 @@ from flask.cli import with_appcontext from apptax.database import db -from apptax.taxonomie.models import Taxref, TaxrefBdcStatutText +from apptax.taxonomie.models import Taxref, TaxrefBdcStatutText, TMetaTaxref from .utils import truncate_bdc_statuts from .taxref_v14 import import_v14, import_bdc_v14 @@ -27,6 +27,12 @@ def taxref(): @with_appcontext def info(): click.echo("TaxRef :") + taxref_version = ( + db.session.query(TMetaTaxref).order_by(TMetaTaxref.taxref_update_date.desc()).scalar() + ) + click.echo( + f"\tVersion de taxref : {taxref_version.taxref_version} ({taxref_version.taxref_update_date})" + ) taxref_count = db.session.query(Taxref.cd_nom).count() click.echo(f"\tNombre de taxons : {taxref_count}") status_count = db.session.query(TaxrefBdcStatutText.id_text).count() diff --git a/apptax/taxonomie/commands/taxref_v15_v16.py b/apptax/taxonomie/commands/taxref_v15_v16.py index a7a3be15..ecee62ef 100644 --- a/apptax/taxonomie/commands/taxref_v15_v16.py +++ b/apptax/taxonomie/commands/taxref_v15_v16.py @@ -17,8 +17,9 @@ import_bdc_statuts, populate_bdc_statut_cor_text_area, populate_enable_bdc_statut_text, + insert_taxref_numversion, ) -from apptax.taxonomie.models import Taxref +from apptax.taxonomie.models import Taxref, TMetaTaxref base_url = "http://geonature.fr/data/inpn/taxonomie/" @@ -129,6 +130,8 @@ def import_taxref(logger, num_version, taxref_archive_name, taxref_file_name): "url", ), ) + insert_taxref_numversion(num_version) + db.session.commit() @click.command() diff --git a/apptax/taxonomie/commands/utils.py b/apptax/taxonomie/commands/utils.py index 791a6e27..fbaf04fc 100644 --- a/apptax/taxonomie/commands/utils.py +++ b/apptax/taxonomie/commands/utils.py @@ -10,6 +10,7 @@ from utils_flask_sqla.migrations.utils import open_remote_file from apptax.database import db +from apptax.taxonomie.models import TMetaTaxref def import_bdc_statuts(logger, base_url, zipfile, status_types_file, status_file): @@ -296,3 +297,8 @@ def copy_from_csv( """ ) table.drop(bind=db.session.connection()) + + +def insert_taxref_numversion(num_version): + taxref_version = TMetaTaxref(taxref_version=f"TAXREF v{num_version}") + db.session.add(taxref_version) diff --git a/apptax/taxonomie/models.py b/apptax/taxonomie/models.py index 8cc3315b..e4350979 100644 --- a/apptax/taxonomie/models.py +++ b/apptax/taxonomie/models.py @@ -444,3 +444,11 @@ class VBdcStatus(db.Model): full_citation = db.Column(db.Unicode, primary_key=True) doc_url = db.Column(db.Unicode) type_value = db.Column(db.Unicode) + + +@serializable +class TMetaTaxref(db.Model): + __tablename__ = "t_meta_taxref" + __table_args__ = {"schema": "taxonomie"} + taxref_version = db.Column(db.Unicode, primary_key=True) + taxref_update_date = db.Column(db.DateTime, default=db.func.now(), nullable=False) diff --git a/apptax/taxonomie/routestaxref.py b/apptax/taxonomie/routestaxref.py index 71b8720a..6d3046f3 100644 --- a/apptax/taxonomie/routestaxref.py +++ b/apptax/taxonomie/routestaxref.py @@ -18,6 +18,7 @@ BibTaxrefHabitats, CorNomListe, BibListes, + TMetaTaxref, ) from .repositories import BdcStatusRepository @@ -38,6 +39,18 @@ def getTaxrefList(): return genericTaxrefList(False, request.args) +@adresses.route("/version", methods=["GET"]) +@json_resp +def getTaxrefVersion(): + """ + Retourne la version de taxref ainsi que ça date de mise à jour + """ + taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.taxref_update_date.desc()).scalar() + if not taxref_version: + return {"msg": "Table t_meta_taxref non peulplée"}, 500 + return taxref_version.as_dict() + + @adresses.route("/bibnoms/", methods=["GET"]) @json_resp def getTaxrefBibtaxonList(): diff --git a/apptax/tests/test_taxref.py b/apptax/tests/test_taxref.py index 71b8b579..390b8d0f 100644 --- a/apptax/tests/test_taxref.py +++ b/apptax/tests/test_taxref.py @@ -1,4 +1,5 @@ import pytest +import json from flask import url_for from schema import Schema, Optional, Or @@ -102,3 +103,8 @@ def test_regneGroup2Inpn_routes(self): def test_bib_routes(self): response = self.client.get(url_for("taxref.get_bib_hab")) assert response.status_code == 200 + + def test_taxrefversion_routes(self): + response = self.client.get(url_for("taxref.getTaxrefVersion")) + assert response.status_code == 200 + assert json.loads(response.data)["taxref_version"] == "TAXREF v16" diff --git a/apptax/tests/test_taxref_last_version.py b/apptax/tests/test_taxref_last_version.py index 22924009..b694f0e3 100644 --- a/apptax/tests/test_taxref_last_version.py +++ b/apptax/tests/test_taxref_last_version.py @@ -4,7 +4,7 @@ pytestmark = pytest.mark.skipif(os.environ.get("CI") != "true", reason="Test for CI only") -from apptax.taxonomie.models import Taxref, TaxrefBdcStatutText +from apptax.taxonomie.models import Taxref, TaxrefBdcStatutText, TMetaTaxref from apptax.taxonomie.commands.utils import populate_enable_bdc_statut_text @@ -40,8 +40,6 @@ def test_enable_bdc_statut(self): nb_bdc_texts = TaxrefBdcStatutText.query.filter(TaxrefBdcStatutText.enable == True).count() assert nb_bdc_texts == 194 - def test_link_bdc_statut_to_areas(self): - text_barc = TaxrefBdcStatutText.query.filter( - TaxrefBdcStatutText.cd_type_statut == "BARC" - ).scalar() - assert len(text_barc.areas) == 96 + def test_taxref_version(self): + taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.taxref_update_date.desc()).scalar() + assert taxref_version.taxref_version == "TAXREF v16" From 05067802d304a99f1886ff371d385d176ce86fb2 Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Sat, 24 Jun 2023 10:26:01 +0200 Subject: [PATCH 2/8] routestaxref.py - Fix help typos --- apptax/taxonomie/routestaxref.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apptax/taxonomie/routestaxref.py b/apptax/taxonomie/routestaxref.py index 6d3046f3..b2dcc248 100644 --- a/apptax/taxonomie/routestaxref.py +++ b/apptax/taxonomie/routestaxref.py @@ -43,11 +43,11 @@ def getTaxrefList(): @json_resp def getTaxrefVersion(): """ - Retourne la version de taxref ainsi que ça date de mise à jour + Retourne la version de Taxref ainsi que sa date de dernière mise à jour """ taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.taxref_update_date.desc()).scalar() if not taxref_version: - return {"msg": "Table t_meta_taxref non peulplée"}, 500 + return {"msg": "Table t_meta_taxref non peuplée"}, 500 return taxref_version.as_dict() @@ -62,11 +62,11 @@ def getSearchInField(field, ilike): """.. http:get:: /taxref/search/(str:field)/(str:ilike) .. :quickref: Taxref; - Retourne les 20 premiers résultat de la table "taxref" pour une + Retourne les 20 premiers résultats de la table "taxref" pour une requête sur le champ `field` avec ILIKE et la valeur `ilike` fournie. L'algorithme Trigramme est utilisé pour établir la correspondance. - :query fields: Permet de récupérer des champs suplémentaire de la + :query fields: Permet de récupérer des champs suplémentaires de la table "taxref" dans la réponse. Séparer les noms des champs par des virgules. :query is_inbibnom: Ajoute une jointure sur la table "bib_noms". @@ -308,8 +308,8 @@ def genericHierarchieSelect(tableHierarchy, rang, parameters): @json_resp def get_regneGroup2Inpn_taxref(): """ - Retourne la liste des règne et groupe 2 - défini par taxref de façon hiérarchique + Retourne la liste des règnes et groupes 2 + définis par Taxref de façon hiérarchique formatage : {'regne1':['grp1', 'grp2'], 'regne2':['grp3', 'grp4']} """ q = ( @@ -335,16 +335,16 @@ def get_AllTaxrefNameByListe(code_liste=None): """ Route utilisée pour les autocompletes Si le paramètre search_name est passé, la requête SQL utilise l'algorithme - des trigrames pour améliorer la pertinence des résultats - Route utilisé par le mobile pour remonter la liste des taxons + des trigrammes pour améliorer la pertinence des résultats + Route utilisée par le mobile pour remonter la liste des taxons params URL: - - code_liste : code de la liste (si id liste est null ou = à -1 on ne prend pas de liste) + - code_liste : code de la liste (si id_liste est null ou = à -1 on ne prend pas de liste) params GET (facultatifs): - - search_name : nom recherché. Recherche basé sur la fonction - ilike de sql avec un remplacement des espaces par % - - regne : filtre sur le regne INPN + - search_name : nom recherché. Recherche basée sur la fonction + ilike de SQL avec un remplacement des espaces par % + - regne : filtre sur le règne INPN - group2_inpn : filtre sur le groupe 2 de l'INPN - - limit: nombre de résultat + - limit: nombre de résultats - offset: numéro de la page """ # Traitement des cas ou code_liste = -1 @@ -363,7 +363,7 @@ def get_AllTaxrefNameByListe(code_liste=None): # Get id_liste try: - # S'il y a une id_liste elle à forcement la valeur -1 + # S'il y a un id_liste elle a forcement la valeur -1 # c-a-d pas de liste if not id_liste: q = ( @@ -399,7 +399,7 @@ def get_AllTaxrefNameByListe(code_liste=None): q = q.order_by( desc(VMTaxrefListForautocomplete.cd_nom == VMTaxrefListForautocomplete.cd_ref) ) - # if no search name no need to order by trigram or cd_nom=cdref - order by PK (use for mobile app) + # if no search name, no need to order by trigram or cd_nom=cdref - order by PK (used for mobile app) else: q = q.order_by(VMTaxrefListForautocomplete.gid) From 23db8756b361ef026e50adca02ff1cc64dc38aec Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Fri, 30 Jun 2023 11:12:40 +0200 Subject: [PATCH 3/8] add route for cor_nom_liste --- apptax/taxonomie/routesbiblistes.py | 23 ++++++++++++++++++++++- apptax/tests/test_biblistes.py | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 apptax/tests/test_biblistes.py diff --git a/apptax/taxonomie/routesbiblistes.py b/apptax/taxonomie/routesbiblistes.py index fff60131..54864d15 100644 --- a/apptax/taxonomie/routesbiblistes.py +++ b/apptax/taxonomie/routesbiblistes.py @@ -5,6 +5,7 @@ from flask import Blueprint, request, current_app from sqlalchemy import func, or_ +from sqlalchemy.orm import joinedload from pypnusershub import routes as fnauth @@ -161,7 +162,6 @@ def getNoms_bibtaxons(idliste): q = q.filter(or_(Taxref.group2_inpn == group2_inpn)) subq = db.session.query(CorNomListe.id_nom).filter(CorNomListe.id_liste == idliste).subquery() - if parameters.get("existing"): q = q.join(subq, subq.c.id_nom == BibNoms.id_nom) else: @@ -223,6 +223,27 @@ def getNoms_bibtaxons(idliste): } +@adresses.route("/cor_nom_liste", methods=["GET"]) +@json_resp +def get_cor_nom_liste(): + limit = request.args.get("limit", 20, int) + page = request.args.get("page", 1, int) + q = CorNomListe.query.options(joinedload("bib_nom")) + total = q.count() + results = q.paginate(page=page, per_page=limit, error_out=False) + items = [] + for r in results.items: + cor_nom_list_dict = r.as_dict(relationships=("bib_nom",), exclude=("id_nom",)) + bib_nom = cor_nom_list_dict.pop("bib_nom") + items.append(dict(cor_nom_list_dict, cd_nom=bib_nom["cd_nom"])) + return { + "items": items, + "total": total, + "limit": limit, + "page": page, + } + + # POST - Ajouter les noms à une liste @adresses.route("/addnoms/", methods=["POST"]) @json_resp diff --git a/apptax/tests/test_biblistes.py b/apptax/tests/test_biblistes.py new file mode 100644 index 00000000..49ad63a6 --- /dev/null +++ b/apptax/tests/test_biblistes.py @@ -0,0 +1,27 @@ +import pytest + +from flask import url_for + +from .fixtures import * +from schema import Schema, Optional, Or + + +@pytest.mark.usefixtures("client_class", "temporary_transaction") +class TestApiBibListe: + schema_cor_nom_liste = Schema( + { + "items": [{"cd_nom": int, "id_liste": int}], + "total": int, + "limit": int, + "page": int, + } + ) + + def test_cor_nom_liste(self, noms_example): + response = self.client.get( + url_for("bib_listes.get_cor_nom_liste"), + ) + assert response.status_code == 200 + data = response.json + assert len(data["items"]) > 0 + self.schema_cor_nom_liste.validate(data) From debd9f867c3c765202425eabea0c187cadeaf601 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Fri, 30 Jun 2023 17:26:27 +0200 Subject: [PATCH 4/8] change t_meta_taxref modelisation --- .../32c5ed42bdbd_add_table_t_meta_taxref.py | 21 ++++++++++--------- .../commands/migrate_taxref/commands_v15.py | 2 +- .../commands/migrate_taxref/commands_v16.py | 2 +- apptax/taxonomie/commands/utils.py | 2 +- apptax/taxonomie/models.py | 5 +++-- apptax/taxonomie/routestaxref.py | 6 ++++-- apptax/tests/test_taxref.py | 2 +- apptax/tests/test_taxref_last_version.py | 4 ++-- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py b/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py index 60031a6d..ab644679 100644 --- a/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py +++ b/apptax/migrations/versions/32c5ed42bdbd_add_table_t_meta_taxref.py @@ -7,7 +7,7 @@ """ import datetime from alembic import op -from sqlalchemy import Column, Unicode, DateTime, func +from sqlalchemy import Column, Unicode, DateTime, Integer, func import sqlalchemy as sa @@ -21,25 +21,26 @@ def upgrade(): op.create_table( "t_meta_taxref", - Column("taxref_version", Unicode, primary_key=True), - Column("taxref_update_date", DateTime, server_default=func.now()), + Column("referencial_name", Unicode, primary_key=True), + Column("version", Integer, primary_key=True), + Column("update_date", DateTime, server_default=func.now()), schema="taxonomie", ) op.execute( """ WITH meta_taxref AS ( - SELECT 1019039 as max_cd_nom, 'TAXREF v16' AS taxref_version + SELECT 1019039 as max_cd_nom, 16 AS taxref_version UNION - SELECT 1002708 as max_cd_nom, 'TAXREF v15' AS taxref_version + SELECT 1002708 as max_cd_nom, 15 AS taxref_version UNION - SELECT 972486 as max_cd_nom, 'TAXREF v14' AS taxref_version + SELECT 972486 as max_cd_nom, 14 AS taxref_version UNION - SELECT 935095 as max_cd_nom, 'TAXREF v13' AS taxref_version + SELECT 935095 as max_cd_nom, 13 AS taxref_version UNION - SELECT 887126 as max_cd_nom, 'TAXREF v11' AS taxref_version + SELECT 887126 as max_cd_nom, 11 AS taxref_version ) - INSERT INTO taxonomie.t_meta_taxref (taxref_version) - SELECT taxref_version + INSERT INTO taxonomie.t_meta_taxref (referencial_name, version) + SELECT 'taxref', taxref_version FROM taxonomie.taxref AS t JOIN meta_taxref m ON t.cd_nom = max_cd_nom diff --git a/apptax/taxonomie/commands/migrate_taxref/commands_v15.py b/apptax/taxonomie/commands/migrate_taxref/commands_v15.py index 04811a2f..e88c096b 100644 --- a/apptax/taxonomie/commands/migrate_taxref/commands_v15.py +++ b/apptax/taxonomie/commands/migrate_taxref/commands_v15.py @@ -137,7 +137,7 @@ def apply_changes( logger.info("Refresh materialized views…") refresh_taxref_vm() - insert_taxref_numversion("15") + insert_taxref_numversion(15) db.session.commit() diff --git a/apptax/taxonomie/commands/migrate_taxref/commands_v16.py b/apptax/taxonomie/commands/migrate_taxref/commands_v16.py index dbce52e0..c64b7524 100644 --- a/apptax/taxonomie/commands/migrate_taxref/commands_v16.py +++ b/apptax/taxonomie/commands/migrate_taxref/commands_v16.py @@ -137,7 +137,7 @@ def apply_changes( logger.info("Refresh materialized views…") refresh_taxref_vm() - insert_taxref_numversion("16") + insert_taxref_numversion(16) db.session.commit() diff --git a/apptax/taxonomie/commands/utils.py b/apptax/taxonomie/commands/utils.py index fbaf04fc..5e42cc5d 100644 --- a/apptax/taxonomie/commands/utils.py +++ b/apptax/taxonomie/commands/utils.py @@ -300,5 +300,5 @@ def copy_from_csv( def insert_taxref_numversion(num_version): - taxref_version = TMetaTaxref(taxref_version=f"TAXREF v{num_version}") + taxref_version = TMetaTaxref(referencial_name="Taxref", version=num_version) db.session.add(taxref_version) diff --git a/apptax/taxonomie/models.py b/apptax/taxonomie/models.py index e4350979..f3a6667a 100644 --- a/apptax/taxonomie/models.py +++ b/apptax/taxonomie/models.py @@ -450,5 +450,6 @@ class VBdcStatus(db.Model): class TMetaTaxref(db.Model): __tablename__ = "t_meta_taxref" __table_args__ = {"schema": "taxonomie"} - taxref_version = db.Column(db.Unicode, primary_key=True) - taxref_update_date = db.Column(db.DateTime, default=db.func.now(), nullable=False) + referencial_name = db.Column(db.Integer, primary_key=True) + version = db.Column(db.Integer) + update_date = db.Column(db.DateTime, default=db.func.now(), nullable=False) diff --git a/apptax/taxonomie/routestaxref.py b/apptax/taxonomie/routestaxref.py index b2dcc248..c8442ff9 100644 --- a/apptax/taxonomie/routestaxref.py +++ b/apptax/taxonomie/routestaxref.py @@ -43,9 +43,11 @@ def getTaxrefList(): @json_resp def getTaxrefVersion(): """ - Retourne la version de Taxref ainsi que sa date de dernière mise à jour + La table TMetaTaxref contient la liste des référentiels contenu dans la table taxref + Cette route renvoie le dernier référentiel qui a été MAJ + (utilisé pour le mobile pour retélécharger le référentiel lorsque celui ci à changé ou en MAJ) """ - taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.taxref_update_date.desc()).scalar() + taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.update_date.desc()).first() if not taxref_version: return {"msg": "Table t_meta_taxref non peuplée"}, 500 return taxref_version.as_dict() diff --git a/apptax/tests/test_taxref.py b/apptax/tests/test_taxref.py index 390b8d0f..5d551db3 100644 --- a/apptax/tests/test_taxref.py +++ b/apptax/tests/test_taxref.py @@ -107,4 +107,4 @@ def test_bib_routes(self): def test_taxrefversion_routes(self): response = self.client.get(url_for("taxref.getTaxrefVersion")) assert response.status_code == 200 - assert json.loads(response.data)["taxref_version"] == "TAXREF v16" + assert json.loads(response.data)["version"] == 16 diff --git a/apptax/tests/test_taxref_last_version.py b/apptax/tests/test_taxref_last_version.py index b694f0e3..91581989 100644 --- a/apptax/tests/test_taxref_last_version.py +++ b/apptax/tests/test_taxref_last_version.py @@ -41,5 +41,5 @@ def test_enable_bdc_statut(self): assert nb_bdc_texts == 194 def test_taxref_version(self): - taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.taxref_update_date.desc()).scalar() - assert taxref_version.taxref_version == "TAXREF v16" + taxref_version = TMetaTaxref.query.order_by(TMetaTaxref.update_date.desc()).scalar() + assert taxref_version.version == 16 From 285325d4a320e9dc2d80f4cd76d97a2a6355dae0 Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Tue, 11 Jul 2023 14:24:31 +0200 Subject: [PATCH 5/8] Update auteurs.rst --- docs/auteurs.rst | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/auteurs.rst b/docs/auteurs.rst index 3853c24b..b0e24de6 100644 --- a/docs/auteurs.rst +++ b/docs/auteurs.rst @@ -11,16 +11,16 @@ Parc national des Ecrins * Élie Bouttier * Quang Pham -.. image:: http://geonature.fr/img/logo-pne.jpg - :target: http://www.ecrins-parcnational.fr +.. image:: https://geonature.fr/img/logo-pne.jpg + :target: https://www.ecrins-parcnational.fr -Parc national des Cevennes +Parc national des Cévennes -------------------------- * Amandine Sahl -.. image:: http://geonature.fr/img/logo-pnc.jpg - :target: http://www.cevennes-parcnational.fr +.. image:: https://geonature.fr/img/logo-pnc.jpg + :target: https://www.cevennes-parcnational.fr Parc national de la Vanoise --------------------------- @@ -59,6 +59,16 @@ LPO France * Maxime Toma +Natural Solutions +----------------- + +* Maxime Vergez + +CREA Mont-Blanc +--------------- + +* Mathieu Roudaut + Autres ------ From a6017a62b2928033426a3af591c6b7e448e75406 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Tue, 11 Jul 2023 14:07:43 +0200 Subject: [PATCH 6/8] bump usershub auth module + dependencies --- dependencies/UsersHub-authentification-module | 2 +- dependencies/Utils-Flask-SQLAlchemy | 2 +- dependencies/Utils-Flask-SQLAlchemy-Geo | 2 +- requirements-dependencies.in | 2 +- requirements-dev.txt | 31 +++++++++---------- requirements.txt | 29 +++++++++-------- 6 files changed, 33 insertions(+), 35 deletions(-) diff --git a/dependencies/UsersHub-authentification-module b/dependencies/UsersHub-authentification-module index 9293dfbb..2c773523 160000 --- a/dependencies/UsersHub-authentification-module +++ b/dependencies/UsersHub-authentification-module @@ -1 +1 @@ -Subproject commit 9293dfbbee453d052932a353ea1c31c7709ea463 +Subproject commit 2c773523883db17936a50d831c394bb6d4b2990d diff --git a/dependencies/Utils-Flask-SQLAlchemy b/dependencies/Utils-Flask-SQLAlchemy index 6fc91a73..1c144eb6 160000 --- a/dependencies/Utils-Flask-SQLAlchemy +++ b/dependencies/Utils-Flask-SQLAlchemy @@ -1 +1 @@ -Subproject commit 6fc91a7314936c50f5b35cf0829abd1fa93f03df +Subproject commit 1c144eb6b8884c6db746bfb01476ac819c5ecf35 diff --git a/dependencies/Utils-Flask-SQLAlchemy-Geo b/dependencies/Utils-Flask-SQLAlchemy-Geo index 84f9a326..2b5002bf 160000 --- a/dependencies/Utils-Flask-SQLAlchemy-Geo +++ b/dependencies/Utils-Flask-SQLAlchemy-Geo @@ -1 +1 @@ -Subproject commit 84f9a326bef2c400b57ab42f36ac36401f8ab537 +Subproject commit 2b5002bf13762d1c49b5d18516cd72d82861f12c diff --git a/requirements-dependencies.in b/requirements-dependencies.in index cae07b0d..dc10bc09 100644 --- a/requirements-dependencies.in +++ b/requirements-dependencies.in @@ -1,3 +1,3 @@ utils-flask-sqlalchemy>=0.3.0,<1.0 -pypnusershub>=1.6.2,<2.0 +pypnusershub>=1.6.8,<2.0 pypn-ref-geo>=1.2.0,<2.0 diff --git a/requirements-dev.txt b/requirements-dev.txt index febadbb2..1810b7b1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --resolver=backtracking requirements-dev.in +# pip-compile requirements-dev.in # -e file:dependencies/RefGeo#egg=pypn-ref-geo # via -r requirements-submodules.in @@ -25,13 +25,13 @@ alembic==1.11.1 # pypnusershub attrs==23.1.0 # via fiona -authlib==1.2.0 +authlib==1.2.1 # via pypnusershub bcrypt==4.0.1 # via pypnusershub -boto3==1.26.153 +boto3==1.28.2 # via -r requirements-common.in -botocore==1.29.153 +botocore==1.31.2 # via # boto3 # s3transfer @@ -41,9 +41,9 @@ certifi==2023.5.7 # requests cffi==1.15.1 # via cryptography -charset-normalizer==3.1.0 +charset-normalizer==3.2.0 # via requests -click==8.1.3 +click==8.1.4 # via # -r requirements-common.in # click-plugins @@ -56,9 +56,9 @@ cligj==0.7.2 # via fiona contextlib2==21.6.0 # via schema -cryptography==41.0.1 +cryptography==41.0.2 # via authlib -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 # via pytest fiona==1.9.4.post1 # via utils-flask-sqlalchemy-geo @@ -75,7 +75,7 @@ flask==2.2.5 # pypnusershub # pytest-flask # utils-flask-sqlalchemy -flask-cors==3.0.10 +flask-cors==4.0.0 # via -r requirements-common.in flask-marshmallow==0.15.0 # via pypnusershub @@ -83,14 +83,14 @@ flask-migrate==4.0.4 # via # -r requirements-common.in # utils-flask-sqlalchemy -flask-sqlalchemy==3.0.3 +flask-sqlalchemy==3.0.5 # via # -r requirements-common.in # flask-migrate # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy -geoalchemy2==0.13.3 +geoalchemy2==0.14.0 # via utils-flask-sqlalchemy-geo geojson==3.0.1 # via utils-flask-sqlalchemy-geo @@ -155,7 +155,7 @@ packaging==23.1 # pytest pillow==9.5.0 # via -r requirements-common.in -pluggy==1.0.0 +pluggy==1.2.0 # via pytest psycopg2==2.9.6 # via @@ -168,7 +168,7 @@ pycparser==2.21 # via cffi pyflakes==2.5.0 # via flake8 -pytest==7.3.2 +pytest==7.4.0 # via # -r requirements-dev.in # pytest-flask @@ -193,9 +193,8 @@ shapely==1.8.5.post1 six==1.16.0 # via # fiona - # flask-cors # python-dateutil -sqlalchemy==1.4.48 +sqlalchemy==1.4.49 # via # -r requirements-common.in # alembic @@ -208,7 +207,7 @@ sqlalchemy==1.4.48 # utils-flask-sqlalchemy-geo tomli==2.0.1 # via pytest -typing-extensions==4.6.3 +typing-extensions==4.7.1 # via # alembic # importlib-metadata diff --git a/requirements.txt b/requirements.txt index 87ac57ef..75d9e1ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --resolver=backtracking requirements.in +# pip-compile requirements.in # alembic==1.11.1 # via @@ -11,13 +11,13 @@ alembic==1.11.1 # pypnusershub attrs==23.1.0 # via fiona -authlib==1.2.0 +authlib==1.2.1 # via pypnusershub bcrypt==4.0.1 # via pypnusershub -boto3==1.26.153 +boto3==1.28.2 # via -r requirements-common.in -botocore==1.29.153 +botocore==1.31.2 # via # boto3 # s3transfer @@ -27,9 +27,9 @@ certifi==2023.5.7 # requests cffi==1.15.1 # via cryptography -charset-normalizer==3.1.0 +charset-normalizer==3.2.0 # via requests -click==8.1.3 +click==8.1.4 # via # -r requirements-common.in # click-plugins @@ -40,7 +40,7 @@ click-plugins==1.1.1 # via fiona cligj==0.7.2 # via fiona -cryptography==41.0.1 +cryptography==41.0.2 # via authlib fiona==1.9.4.post1 # via utils-flask-sqlalchemy-geo @@ -54,7 +54,7 @@ flask==2.2.5 # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy -flask-cors==3.0.10 +flask-cors==4.0.0 # via -r requirements-common.in flask-marshmallow==0.15.0 # via pypnusershub @@ -62,14 +62,14 @@ flask-migrate==4.0.4 # via # -r requirements-common.in # utils-flask-sqlalchemy -flask-sqlalchemy==3.0.3 +flask-sqlalchemy==3.0.5 # via # -r requirements-common.in # flask-migrate # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy -geoalchemy2==0.13.3 +geoalchemy2==0.14.0 # via utils-flask-sqlalchemy-geo geojson==3.0.1 # via utils-flask-sqlalchemy-geo @@ -79,7 +79,7 @@ gunicorn==20.1.0 # via -r requirements-common.in idna==3.4 # via requests -importlib-metadata==6.6.0 +importlib-metadata==6.7.0 # via # alembic # attrs @@ -135,7 +135,7 @@ pycparser==2.21 # via cffi pypn-ref-geo==1.3.0 # via -r requirements-dependencies.in -pypnusershub==1.6.7 +pypnusershub==1.6.8 # via -r requirements-dependencies.in python-dateutil==2.8.2 # via @@ -154,9 +154,8 @@ shapely==1.8.5.post1 six==1.16.0 # via # fiona - # flask-cors # python-dateutil -sqlalchemy==1.4.48 +sqlalchemy==1.4.49 # via # -r requirements-common.in # alembic @@ -167,7 +166,7 @@ sqlalchemy==1.4.48 # pypnusershub # utils-flask-sqlalchemy # utils-flask-sqlalchemy-geo -typing-extensions==4.6.3 +typing-extensions==4.7.1 # via # alembic # importlib-metadata From 78b12469d25bef7696aa5fac8738d58a9eb53a94 Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Tue, 11 Jul 2023 14:37:20 +0200 Subject: [PATCH 7/8] Changelog 1.12.0 --- docs/changelog.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 46b5d97e..c5379650 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,12 @@ +1.12.0 (2023-07-11) +=================== + +**🚀 Nouveautés** + +* Ajout d'une table `t_meta_taxref` stockant la version du référentiel taxonomique ainsi que de sa date de dernière mise à jour, et de la route `/version` associée (#394) +* Ajout d'une route `cor_nom_liste` pour accéder au contenu de cette table (#406) +* Mise à jour des dépendances Python (#410) + 1.11.3 (2023-06-27) =================== From 1f9b70b6a16a18327c20231413f7c39fd6537f4d Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Tue, 11 Jul 2023 14:37:44 +0200 Subject: [PATCH 8/8] Bump VERSION - 1.12.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0a5af26d..0eed1a29 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.3 +1.12.0