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

Load types medias from taxref route and bib_attributs related attributs #583

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

andriacap
Copy link

@andriacap andriacap commented Nov 21, 2024

Cette PR propose de palier au besoin de récupération des informations du "type" de média associés aux taxons. Il propose également de remonter les informations liés à bib_attributs (informations qui pourrait être utiles également pour certains besoins dont GN Citizen).

Pour remonter ces informations liées aux taxons d'une liste avec comme id_liste = 101 par exemple voici la route à appeler : /taxref?id_liste=101&fields=medias.types,attributs.bib_attribut

Le développement proposé ici propose une modifications des jointures réalisées sur la base de ce que l'on passe en query params et permet de garder la souplesse du code actuel afin de ne pas les charger systématiquement.

Partie de Réponse à l'appel de la route "/taxref?id_liste=101&fields=medias.types,attributs,attributs.bib_attribut"
....
 {
      "attributs": [
        {
          "bib_attribut": {
            "desc_attribut": "Test attribut",
            "group2_inpn": null,
            "id_attribut": 105,
            "id_theme": 1,
            "label_attribut": "nom_fran\u00e7ais",
            "liste_valeur_attribut": null,
            "nom_attribut": "nom_fran\u00e7ais",
            "obligatoire": false,
            "ordre": null,
            "regne": null,
            "type_attribut": "text ",
            "type_widget": "text"
          },
          "cd_ref": 534742,
          "id_attribut": 105,
          "valeur_attribut": "M\u00e9sange bleue"
        }
      ],
      "cd_nom": 534742,
      "cd_ref": 534742,
      "cd_sup": 836858,
      "cd_taxsup": 836858,
      "classe": "Aves",
      "famille": "Paridae",
      "group1_inpn": "Chord\u00e9s",
      "group2_inpn": "Oiseaux",
      "group3_inpn": "Autres",
      "id_habitat": 3,
      "id_rang": "ES",
      "id_statut": "P",
      "lb_auteur": "(Linnaeus, 1758)",
      "lb_nom": "Cyanistes caeruleus",
      "medias": [
        {
          "auteur": null,
          "cd_ref": 534742,
          "chemin": "534742_mesange_bleue-4967.jpg",
          "desc_media": "",
          "id_media": 4,
          "id_type": 1,
          "is_public": true,
          "licence": null,
          "media_url": "http://127.0.0.1:5000/home/andriac/applications/dev/gn-citizen-dev/taxhub/apptax/media/taxhub/534742_mesange_bleue-4967.jpg",
          "source": null,
          "titre": "M\u00e9sange bleu",
          "types": {
            "desc_type_media": "Photo principale du taxon \u00e0 utiliser pour les vignettes par exemple",
            "id_type": 1,
            "nom_type_media": "Photo_principale"
          },
          "url": null
        }
      ],
      "nom_complet": "Cyanistes caeruleus (Linnaeus, 1758)",
      "nom_complet_html": "<i>Cyanistes caeruleus</i> (Linnaeus, 1758)",
      "nom_valide": "Cyanistes caeruleus (Linnaeus, 1758)",
      "nom_vern": "M\u00e9sange bleue",
      "nom_vern_eng": null,
      "ordre": "Passeriformes",
      "phylum": "Chordata",
      "regne": "Animalia",
      "sous_famille": null,
      "tribu": null,
      "url": "https://inpn.mnhn.fr/espece/cd_nom/534742"
    }
    ...

Voir issue : #582

if fields query params is equal to "medias.types" or
"attributs.bib_attributs" then join is loaded.

Reviewed-by: andriacap
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 15.78947% with 16 lines in your changes missing coverage. Please review.

Project coverage is 52.06%. Comparing base (18b662f) to head (7ca8758).

Files with missing lines Patch % Lines
apptax/taxonomie/models.py 5.88% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #583      +/-   ##
===========================================
- Coverage    52.34%   52.06%   -0.29%     
===========================================
  Files           37       37              
  Lines         2432     2451      +19     
===========================================
+ Hits          1273     1276       +3     
- Misses        1159     1175      +16     
Flag Coverage Δ
pytest 52.06% <15.78%> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant