get arrondissement mairie in case of lyon city (#42813)

This commit is contained in:
Frédéric Péters 2020-05-13 15:12:08 +02:00
parent cec2486187
commit c24baefb06
1 changed files with 7 additions and 1 deletions

View File

@ -565,8 +565,8 @@ def get_suggestions(request, user_data, places_data):
}
pollen_tile = {'key': 'pollen'}
addresses = []
city = user_data.get('city') or user_data.get('address_city')
zipcode = user_data.get('zipcode') or user_data.get('address_zipcode')
if city:
# get commune tile for the user city
maplayer = MapLayer.objects.get(slug='mairie')
@ -577,6 +577,12 @@ def get_suggestions(request, user_data, places_data):
pass
else:
city_slug = slugify(city)
if city_slug == 'lyon' and zipcode:
try:
city_slug = 'lyon-' + (int(zipcode) - 69000)
except ValueError:
# fallback to hotel de ville
city_slug = 'ville-de-lyon'
if data_result.get('features'):
for feature in data_result['features']:
if 'Annexe' in feature['properties']['nom']: