Fix insights search
This commit is contained in:
parent
822c474867
commit
de42dcee03
|
@ -548,8 +548,8 @@ def query_results(
|
|||
return context
|
||||
|
||||
|
||||
def query_single_result(request):
|
||||
context = query_results(request, request.POST.dict(), size=100)
|
||||
def query_single_result(request, query_params):
|
||||
context = query_results(request, query_params, size=100)
|
||||
|
||||
if not context:
|
||||
return {"message": "Failed to run query", "message_class": "danger"}
|
||||
|
|
|
@ -156,12 +156,10 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
{% if user|has_plan:'drilldown' %}
|
||||
<a class="navbar-item" href="{% url 'insights' %}">
|
||||
Insights
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if perms.core.use_insights %}
|
||||
<a class="navbar-item" href="{% url 'insights' %}">
|
||||
Insights
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="navbar-item add-button">
|
||||
Install
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
{% csrf_token %}
|
||||
<div class="field has-addons">
|
||||
<div class="control is-expanded has-icons-left">
|
||||
<input id="query" name="query" class="input" type="text" placeholder="nickname">
|
||||
<input id="query_full" name="query_full" class="input" type="text" placeholder="nickname">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-magnifying-glass"></i>
|
||||
</span>
|
||||
|
|
|
@ -33,7 +33,10 @@ class InsightsSearch(LoginRequiredMixin, PermissionRequiredMixin, View):
|
|||
permission_required = "use_insights"
|
||||
|
||||
def post(self, request):
|
||||
context = query_single_result(request)
|
||||
query_params = request.POST.dict()
|
||||
if "query_full" in query_params:
|
||||
query_params["query_full"] = "nick: " + query_params["query_full"]
|
||||
context = query_single_result(request, query_params)
|
||||
if not context:
|
||||
return HttpResponseForbidden()
|
||||
return render(request, self.template_name, context)
|
||||
|
|
Loading…
Reference in New Issue