mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-12-14 22:45:16 +01:00
Solve bug in search field
This commit is contained in:
@@ -15,14 +15,19 @@
|
||||
<h3>{% trans "Results" %}</h3>
|
||||
|
||||
<div id="search-results">
|
||||
{% regroup object_list by model_name as categories %}
|
||||
{% for category in categories %}
|
||||
<h4>{% trans category.grouper|capfirst %}</h4>
|
||||
{% with table=category.list|search_table %}
|
||||
{% render_table table %}
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
{% if has_results %}
|
||||
{% regroup object_list by model_name as categories %}
|
||||
{% for category in categories %}
|
||||
{% if category.grouper %}
|
||||
<h4>{% trans category.grouper|capfirst %}</h4>
|
||||
{% with table=category.list|search_table %}
|
||||
{% render_table table %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>{% trans "No results found." %}</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -46,4 +46,14 @@ class LoginRequiredTemplateView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
|
||||
class AdminSearchView(AdminMixin, SearchView):
|
||||
pass
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
results = context["object_list"]
|
||||
|
||||
context["has_results"] = any(
|
||||
getattr(result, "model_name", None)
|
||||
for result in results
|
||||
)
|
||||
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user