From 0aac4a0cbcbc7d1b97118d05bce1d47f130f07b0 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 28 Sep 2018 12:07:59 +0200 Subject: Fix get tiny url with truncate parameters --- chimere/views.py | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/chimere/views.py b/chimere/views.py index b6c03b8..1e89bd2 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -1017,24 +1017,26 @@ def getTinyfiedUrl(request, parameters, area_name=''): map_name += " - " + response_dct["area"].name text = "" - item_id = parameters.split(';')[4] - if item_id and "-" in item_id: - cls = None - if item_id.startswith('point-'): - cls = models.Marker - elif item_id.startswith('route-'): - cls = models.Route - elif item_id.startswith('polygon-'): - cls = models.Polygon - item_id = item_id.split("-")[1] - if cls: - try: - text = str(cls.objects.get(id=item_id)) - text = str( - _("Share a point of interest on the map {}: ") - ).format(map_name) + text - except (cls.DoesNotExist): - pass + parameter_list = parameters.split(';') + if len(parameter_list) >= 5: + item_id = parameter_list[4] + if item_id and "-" in item_id: + cls = None + if item_id.startswith('point-'): + cls = models.Marker + elif item_id.startswith('route-'): + cls = models.Route + elif item_id.startswith('polygon-'): + cls = models.Polygon + item_id = item_id.split("-")[1] + if cls: + try: + text = str(cls.objects.get(id=item_id)) + text = str( + _("Share a point of interest on the map {}: ") + ).format(map_name) + text + except (cls.DoesNotExist): + pass if not text: text = str( _("Share a point of interest on the map {}") -- cgit v1.2.3