From 26c0b67abba79814efca86c2c914de099246f411 Mon Sep 17 00:00:00 2001 From: Maxime Vergez Date: Mon, 3 Jul 2023 17:41:59 +0200 Subject: [PATCH] feat(api): route to get regne with group3 inpn --- apptax/taxonomie/routestaxref.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apptax/taxonomie/routestaxref.py b/apptax/taxonomie/routestaxref.py index 71b8720a..0c88d799 100644 --- a/apptax/taxonomie/routestaxref.py +++ b/apptax/taxonomie/routestaxref.py @@ -314,6 +314,28 @@ def get_regneGroup2Inpn_taxref(): results[d.regne] = ["", d.group2_inpn] return results +@adresses.route("/regnewithgroupe3", methods=["GET"]) +@json_resp +def get_regneGroup3Inpn_taxref(): + """ + Retourne la liste des règne et groupe 2 + défini par taxref de façon hiérarchique + formatage : {'regne1':['grp1', 'grp2'], 'regne2':['grp3', 'grp4']} + """ + q = ( + db.session.query(Taxref.regne, Taxref.group3_inpn) + .distinct(Taxref.regne, Taxref.group3_inpn) + .filter(Taxref.regne != None) + .filter(Taxref.group3_inpn != None) + ) + data = q.all() + results = {"": [""]} + for d in data: + if d.regne in results: + results[d.regne].append(d.group3_inpn) + else: + results[d.regne] = ["", d.group3_inpn] + return results @adresses.route("/allnamebylist/", methods=["GET"]) @adresses.route("/allnamebylist", methods=["GET"])