From 7791e96809f4978c5c1ae652551037388e078b75 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 11 Aug 2022 23:09:53 +0100 Subject: [PATCH] Fix meta --- core/lib/opensearch.py | 17 +++++++++++------ core/templates/ui/insights/info.html | 1 + core/templates/ui/insights/insights.html | 1 + core/views/ui/insights.py | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index 8afefcc..51c384c 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -187,7 +187,6 @@ def query_results(request, query_params, size=None): return {"message": message, "class": message_class} if source != "all": add_bool.append({"src": source}) - if set({"from_date", "to_date", "from_time", "to_time"}).issubset( query_params.keys() ): @@ -267,6 +266,7 @@ def query_results(request, query_params, size=None): search_query["query"]["bool"]["must_not"] = [item] if sort: search_query["sort"] = sort + if "index" in query_params: if not request.user.is_superuser: message = "How did you get here?" @@ -340,12 +340,17 @@ def query_results(request, query_params, size=None): def query_single_result(request): - context = query_results(request, 1) - dedup_set = {item["nick"] for item in context["results"]} - if dedup_set: - context["item"] = context["results"][0] + context = query_results(request, request.POST.dict(), size=100) - return (1, context) + if not context: + return {"message": "Failed to run query", "message_class": "danger"} + if "message" in context: + return context + dedup_set = {item["nick"] for item in context["object_list"]} + if dedup_set: + context["item"] = context["object_list"][0] + + return context def construct_query(query, size): diff --git a/core/templates/ui/insights/info.html b/core/templates/ui/insights/info.html index 2b3cdf6..ebb7dd7 100644 --- a/core/templates/ui/insights/info.html +++ b/core/templates/ui/insights/info.html @@ -19,6 +19,7 @@ hx-swap="outerHTML">
+ {% include 'partials/notify.html' %} {% if item is not None %}
diff --git a/core/templates/ui/insights/insights.html b/core/templates/ui/insights/insights.html index d7eabd1..61452cc 100644 --- a/core/templates/ui/insights/insights.html +++ b/core/templates/ui/insights/insights.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load static %} {% block content %} + {% include 'partials/notify.html' %}