This commit is contained in:
Mark Veidemanis 2022-08-11 23:09:53 +01:00
parent 5fd6b887de
commit 7791e96809
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 14 additions and 7 deletions

View File

@ -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):

View File

@ -19,6 +19,7 @@
hx-swap="outerHTML">
</div>
<div id="info">
{% include 'partials/notify.html' %}
{% if item is not None %}
<div class="content" style="max-height: 30em; overflow: auto;">
<div class="table-container">

View File

@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
{% include 'partials/notify.html' %}
<script>
// tabbed browsing for the modal
function initTabs() {

View File

@ -37,7 +37,7 @@ class InsightsSearch(LoginRequiredMixin, View):
def post(self, request):
if not request.user.has_plan(self.plan_name):
return HttpResponseForbidden()
results, context = query_single_result(request)
context = query_single_result(request)
if not context:
return HttpResponseForbidden()
return render(request, self.template_name, context)