Commit 78068152 authored by Pierre Arnaud's avatar Pierre Arnaud

Fix PTUs bug

parent 26d62923
......@@ -348,6 +348,7 @@ def territories(request):
else:
return error
ptu_fullname = ""
# Get infos about territory
url = '{}/territory'.format(territoria_api)
json_get_territoire_info = requests.get(url, params=dict(id=territory_id)).json()
......@@ -357,7 +358,6 @@ def territories(request):
full_name_and_cp = json_get_territoire_info['data']['main_postal_distribution'] + ' (' + json_get_territoire_info['data']['type_name'] + ')'
else:
return error
ptu_name = ""
for el in json_get_territoire_info["data"]["ancestors_kind_code"]:
if el["kind"] == "Country":
......@@ -371,7 +371,8 @@ def territories(request):
department_name = department_data["full_name"]
department_fullname = department_data['main_postal_distribution'] + ' (' + department_data['type_name'] + ')'
elif el["kind"] == "UrbanTransportsPerimeterOfFrance":
ptu_name = el["kind"]
ptu_data = requests.get(url, params=dict(kind="UrbanTransportsPerimeterOfFrance", code=el["code"])).json()["data"]
ptu_fullname = ptu_data["main_postal_distribution"] + ' (' + ptu_data['type_name'] + ')'
# Get territory's service infos
url = '{}/poi/search'.format(petitpois_api)
......@@ -453,7 +454,7 @@ def territories(request):
or department_fullname in territories \
or region_fullname in territories \
or name == 'france' or name == 'france-metropolitaine' \
or ptu_name:
or ptu_fullname in territories:
if el.get("multimodal") == 1:
parse_result["multimodal"].append(el)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment