|
19 | 19 | from gncitizen.utils.media import save_upload_files |
20 | 20 | from gncitizen.utils.taxonomy import ( |
21 | 21 | get_taxa_by_cd_nom, |
22 | | - taxhub_rest_get_taxon_list, |
23 | 22 | set_taxa_info_from_taxhub, |
| 23 | + taxhub_rest_get_taxon_list, |
24 | 24 | ) |
25 | 25 | from server import db |
26 | | -from shapely.geometry import shape |
| 26 | +from shapely.geometry import Point, shape |
27 | 27 | from sqlalchemy import desc |
28 | 28 | from utils_flask_sqla.response import json_resp |
29 | 29 |
|
@@ -247,6 +247,7 @@ def post_observation(): |
247 | 247 | ObservationMediaModel, |
248 | 248 | ) |
249 | 249 | current_app.logger.debug("[post_observation] ObsTax UPLOAD FILE {}".format(file)) |
| 250 | + |
250 | 251 | newobs = ( |
251 | 252 | db.session.query(ObservationModel) |
252 | 253 | .options(db.joinedload(ObservationModel.medias)) |
@@ -300,7 +301,6 @@ def get_all_observations() -> Union[FeatureCollection, Tuple[Dict, int]]: |
300 | 301 | paginate = "per_page" in args |
301 | 302 | per_page = int(args.pop("per_page", 1000)) |
302 | 303 | page = int(args.pop("page", 1)) |
303 | | - cd_nom_list = [] |
304 | 304 | id_role = get_id_role_if_exists() |
305 | 305 |
|
306 | 306 | if validation_process and id_role: |
@@ -329,16 +329,18 @@ def get_all_observations() -> Union[FeatureCollection, Tuple[Dict, int]]: |
329 | 329 | observations = query.all() |
330 | 330 | features = [obs.get_feature() for obs in observations] |
331 | 331 |
|
| 332 | + id_taxonomy_list = None |
| 333 | + params = {} |
332 | 334 | if observations: |
333 | 335 | id_taxonomy_list = observations[0].program_ref.taxonomy_list |
334 | | - cd_nom_list = ",".join(map(str, {obs.cd_nom for obs in observations})) |
335 | | - params = {"cd_nom": cd_nom_list} if cd_nom_list else {} |
336 | | - else: |
337 | | - id_taxonomy_list = None |
338 | | - params = {} |
339 | | - |
340 | | - if id_taxonomy_list: |
341 | | - taxon_list_data = taxhub_rest_get_taxon_list(id_taxonomy_list, params) |
| 336 | + cd_nom_list = map(str, {obs.cd_nom for obs in observations}) |
| 337 | + if cd_nom_list: |
| 338 | + params["cd_nom"] = ",".join(cd_nom_list) |
| 339 | + if id_taxonomy_list: |
| 340 | + params["id_liste"] = id_taxonomy_list |
| 341 | + |
| 342 | + if id_taxonomy_list or cd_nom_list: |
| 343 | + taxon_list_data = taxhub_rest_get_taxon_list(params_to_update=params) |
342 | 344 | features_with_taxhub_info = set_taxa_info_from_taxhub(taxon_list_data, features) |
343 | 345 | else: |
344 | 346 | features_with_taxhub_info = features |
@@ -503,7 +505,10 @@ def update_observation(): |
503 | 505 | try: |
504 | 506 | observer = obs_to_update_obj.observer |
505 | 507 | send_user_email( |
506 | | - subject=current_app.config["VALIDATION_EMAIL"]["SUBJECT"], |
| 508 | + subject=current_app.config["VALIDATION_EMAIL"]["SUBJECT"].format( |
| 509 | + program=f"{obs_to_update_obj.program_ref.title}", |
| 510 | + observation=f"{obs_to_update_obj.name} (#{obs_to_update_obj.id_observation})", |
| 511 | + ), |
507 | 512 | to=observer.email, |
508 | 513 | html_message=current_app.config["VALIDATION_EMAIL"][ |
509 | 514 | "HTML_TEMPLATE" |
|
0 commit comments