diff options
Diffstat (limited to 'chimere/views.py')
-rw-r--r-- | chimere/views.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/chimere/views.py b/chimere/views.py index f6014b2..cdf9b42 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -1369,21 +1369,29 @@ class SearchView(FormView): start = (page - 1) * self.results_per_page end = page * self.results_per_page - 1 for model in [models.Marker, models.Route, models.Polygon]: - if len(results) > end - len(results): - continue res, _has_next = model.search( query, area=area, get_json=True, - slice=[start, end], check_next=True) - if _has_next: - has_next = True - if res: - if start: - end = end - start - start = 0 - end -= len(res) results += res - return results, has_next + duplicate_res = [] + for r in results: + extra_icons = [] + if 'extra_icons' in r['properties']: + extra_icons = r['properties']['extra_icons'] + duplicate_res.append(r) + for extra_icon in extra_icons: + data = r.copy() + data['properties'] = r['properties'].copy() + data['properties'].update(extra_icon) + duplicate_res.append(data) + results = list( + sorted(duplicate_res, + key=lambda x: (x['properties']['category_name'], + x['properties']['name'])) + ) + if len(results) <= start: + return [], False + return results[start:end], len(results) > end def get_context_data(self, **kwargs): context = super(SearchView, self).get_context_data(**kwargs) |