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

Compatibility with TaxHubV2 #513

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions backend/gn_module_import/checks/sql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from geonature.core.gn_synthese.models import Synthese, TSources
from ref_geo.models import LAreas, BibAreasTypes
from pypnnomenclature.models import TNomenclatures, BibNomenclaturesTypes
from apptax.taxonomie.models import Taxref, CorNomListe, BibNoms
from apptax.taxonomie.models import Taxref, cor_nom_liste
from pypn_habref_api.models import Habref


Expand Down Expand Up @@ -211,9 +211,10 @@ def check_cd_nom(imprt, fields):
# Filter out on a taxhub list if provided
list_id = current_app.config["IMPORT"].get("ID_LIST_TAXA_RESTRICTION", None)
if list_id is not None:
reference_table = join(Taxref, BibNoms).join(
CorNomListe,
sa.and_(BibNoms.id_nom == CorNomListe.id_nom, CorNomListe.id_liste == list_id),
reference_table = join(
Taxref,
cor_nom_liste,
sa.and_(cor_nom_liste.c.id_liste == list_id, Taxref.cd_nom == cor_nom_liste.c.cd_nom),
)
else:
reference_table = Taxref
Expand Down
16 changes: 6 additions & 10 deletions backend/gn_module_import/tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from werkzeug.datastructures import Headers
from werkzeug.exceptions import Unauthorized, Forbidden, BadRequest, Conflict
from jsonschema import validate as validate_json
from sqlalchemy import func
from sqlalchemy import func, insert
from sqlalchemy.sql.expression import select

from apptax.taxonomie.models import BibListes, CorNomListe, BibNoms
from apptax.taxonomie.models import BibListes, cor_nom_liste
from geonature.utils.env import db
from geonature.core.gn_permissions.tools import (
get_scopes_by_action as _get_scopes_by_action,
Expand Down Expand Up @@ -282,16 +282,12 @@ def sample_taxhub_list():
cd_nom = 67111
with db.session.begin_nested():
id_list_not_exist = (db.session.query(func.max(BibListes.id_liste)).scalar() or 0) + 1
bibTaxon = db.session.query(BibNoms).filter(BibNoms.cd_nom == cd_nom).first()
if bibTaxon is None:
bibTaxon = BibNoms(cd_nom=cd_nom, cd_ref=cd_nom)
db.session.add(bibTaxon)
taxa_list = BibListes(
id_liste=id_list_not_exist, nom_liste="test", code_liste="test", picto=""
)
taxa_list = BibListes(id_liste=id_list_not_exist, nom_liste="test", code_liste="test")
db.session.add(taxa_list)
with db.session.begin_nested():
db.session.add(CorNomListe(id_nom=bibTaxon.id_nom, id_liste=taxa_list.id_liste))
db.session.execute(
insert(cor_nom_liste).values(cd_nom=cd_nom, id_liste=taxa_list.id_liste)
)
return taxa_list


Expand Down
2 changes: 1 addition & 1 deletion dependencies/GeoNature
Submodule GeoNature updated 255 files
Loading