Skip to content

Commit

Permalink
feat(api): route to get regne with group3 inpn
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vergez committed Jul 3, 2023
1 parent da92c12 commit 26c0b67
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apptax/taxonomie/routestaxref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<string:code_liste>", methods=["GET"])
@adresses.route("/allnamebylist", methods=["GET"])
Expand Down

0 comments on commit 26c0b67

Please sign in to comment.