Skip to content

Commit

Permalink
Feat frontend/synthese: add BDC status text infos to observation modal
Browse files Browse the repository at this point in the history
Display the texts (status) when the cd_ref and the location of the observation match the texts.

Resolve #1492.
  • Loading branch information
jpm-cbna committed Nov 19, 2021
1 parent f73f4eb commit f675140
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 119 deletions.
24 changes: 21 additions & 3 deletions backend/geonature/core/gn_synthese/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pypn_habref_api.models import Habref

from geonature.core.gn_meta.models import TDatasets, TAcquisitionFramework
from geonature.core.ref_geo.models import LAreas
from geonature.core.ref_geo.models import LAreas, CorAreaStatus
from geonature.core.ref_geo.models import LiMunicipalities
from geonature.core.gn_commons.models import THistoryActions, TValidations, TMedias
from geonature.utils.env import DB
Expand Down Expand Up @@ -350,12 +350,30 @@ class SyntheseOneRecord(VSyntheseDecodeNomenclatures):

habitat = DB.relationship(Habref, lazy="joined")

source = DB.relationship(TSources)
source = DB.relationship(
"TSources",
primaryjoin=(TSources.id_source == id_source),
foreign_keys=[id_source],
)

areas = DB.relationship(
"LAreas",
secondary=corAreaSynthese,
)
datasets = DB.relationship(TDatasets)

areas_status = DB.relationship(
"CorAreaStatus",
secondary=corAreaSynthese,
primaryjoin=(CorAreaSynthese.id_synthese == id_synthese),
secondaryjoin=(CorAreaSynthese.id_area == CorAreaStatus.id_area),
)

datasets = DB.relationship(
"TDatasets",
primaryjoin=(TDatasets.id_dataset == id_dataset),
foreign_keys=[id_dataset],
)

acquisition_framework = DB.relationship(
"TAcquisitionFramework",
uselist=False,
Expand Down
39 changes: 2 additions & 37 deletions backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,48 +266,13 @@ def get_one_synthese(id_synthese):
)
)
try:

data = q.one()
geojson = data[0].as_geofeature(
"the_geom_4326", "id_synthese",
depth=2,
# fields=[
# "unique_id_sinpsource",
# "areas",
# "areas.area_type",
# "datasets",
# "acquisition_framework",
# "cor_observers",
# "validations",
# "medias",
# "nat_obj_geo",
# "grp_typ",
# "obs_technique",
# "bio_status",
# "bio_condition",
# "naturalness",
# "exist_proof",
# "valid_status",
# "diffusion_level",
# "life_stage",
# "sex",
# "obj_count",
# "type_count",
# "sensitivity",
# "observation_status",
# "blurring",
# "source_status",
# "occ_behaviour",
# "occ_stat_biogeo"
# ]
)
)
geojson["properties"]["actors"] = data[1]
# synthese_as_dict = data[0].as_dict(
# depth=2,
# )

# synthese_as_dict["actors"] = data[1]
# return jsonify(synthese_as_dict)
geojson["properties"]["areas_status"] = [d['cd_sig'] for d in synthese_as_dict["areas_status"]]
return jsonify(geojson)
except exc.NoResultFound:
return None
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/app/GN2CommonModule/form/data-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,14 @@ export class DataFormService {
});
}

getTaxonInfo(cd_nom: number) {
return this._http.get<Taxon>(`${AppConfig.API_TAXHUB}/taxref/${cd_nom}`);
getTaxonInfo(cd_nom: number, areasStatus?: Array<string>) {
let query_string = new HttpParams();
if (areasStatus) {
query_string = query_string.append('areas_status', areasStatus.join(','));
}
return this._http.get<Taxon>(`${AppConfig.API_TAXHUB}/taxref/${cd_nom}`, {
params: query_string
});
}

getTaxonAttributsAndMedia(cd_nom: number, id_attributs?: Array<number>) {
Expand Down
Loading

0 comments on commit f675140

Please sign in to comment.