diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py index 343717594..a5acaca2f 100644 --- a/ietf/doc/views_search.py +++ b/ietf/doc/views_search.py @@ -349,10 +349,19 @@ def retrieve_search_results(form, all_types=False): if hasattr(form.data, "urlencode"): # form was fed a Django QueryDict, not local plain dict d = form.data.copy() for h in meta['headers']: - d["sort"] = h["key"] - h["sort_url"] = "?" + d.urlencode() - if h['key'] == query.get('sort'): + sort = query.get('sort') + if sort.endswith(h['key']): h['sorted'] = True + if sort.startswith('-'): + h['direction'] = 'desc' + d["sort"] = h["key"] + else: + h['direction'] = 'asc' + d["sort"] = "-" + h["key"] + else: + d["sort"] = h["key"] + h["sort_url"] = "?" + d.urlencode() + return (results, meta) diff --git a/ietf/templates/doc/search/search_results.html b/ietf/templates/doc/search/search_results.html index 3d35b4714..81349b260 100644 --- a/ietf/templates/doc/search/search_results.html +++ b/ietf/templates/doc/search/search_results.html @@ -26,7 +26,13 @@ {% if "sort_url" in h %} {{ h.title }} - {% if h.sorted %}{% endif %} + {% if h.sorted and meta.max %} + {% if h.direction == "asc" %} + + {% else %} + + {% endif %} + {% endif %} {% else %} {{ h.title }}