Display the number of maps on search results page
This commit is contained in:
parent
60ac2dc83a
commit
3edad3976d
2 changed files with 15 additions and 6 deletions
|
@ -7,11 +7,18 @@
|
||||||
{% if q %}
|
{% if q %}
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="map_list row">
|
<div class="map_list row">
|
||||||
{% if maps %}
|
{% if maps %}
|
||||||
{% include "umap/map_list.html" with prefix='search_map' %}
|
<h2>
|
||||||
{% else %}
|
{% blocktranslate count counter=count %}
|
||||||
{% trans "Not map found." %}
|
{{ count }} map found:
|
||||||
{% endif %}
|
{% plural %}
|
||||||
|
{{ count }} maps found:
|
||||||
|
{% endblocktranslate %}
|
||||||
|
</h2>
|
||||||
|
{% include "umap/map_list.html" with prefix='search_map' %}
|
||||||
|
{% else %}
|
||||||
|
<h2>{% trans "No map found." %}</h2>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -212,6 +212,7 @@ class Search(TemplateView, PaginatorMixin):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
q = self.request.GET.get("q")
|
q = self.request.GET.get("q")
|
||||||
|
qs_count = 0
|
||||||
results = []
|
results = []
|
||||||
if q:
|
if q:
|
||||||
vector = SearchVector("name", config=settings.UMAP_SEARCH_CONFIGURATION)
|
vector = SearchVector("name", config=settings.UMAP_SEARCH_CONFIGURATION)
|
||||||
|
@ -220,8 +221,9 @@ class Search(TemplateView, PaginatorMixin):
|
||||||
)
|
)
|
||||||
qs = Map.objects.annotate(search=vector).filter(search=query)
|
qs = Map.objects.annotate(search=vector).filter(search=query)
|
||||||
qs = qs.filter(share_status=Map.PUBLIC).order_by("-modified_at")
|
qs = qs.filter(share_status=Map.PUBLIC).order_by("-modified_at")
|
||||||
|
qs_count = qs.count()
|
||||||
results = self.paginate(qs)
|
results = self.paginate(qs)
|
||||||
kwargs.update({"maps": results, "q": q})
|
kwargs.update({"maps": results, "count": qs_count, "q": q})
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def get_template_names(self):
|
def get_template_names(self):
|
||||||
|
|
Loading…
Reference in a new issue