Fix insights search

This commit is contained in:
Mark Veidemanis 2022-08-26 21:03:21 +01:00
parent 822c474867
commit de42dcee03
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 11 additions and 10 deletions

View File

@ -548,8 +548,8 @@ def query_results(
return context return context
def query_single_result(request): def query_single_result(request, query_params):
context = query_results(request, request.POST.dict(), size=100) context = query_results(request, query_params, size=100)
if not context: if not context:
return {"message": "Failed to run query", "message_class": "danger"} return {"message": "Failed to run query", "message_class": "danger"}

View File

@ -156,13 +156,11 @@
</div> </div>
{% endif %} {% endif %}
{% if user.is_authenticated %} {% if perms.core.use_insights %}
{% if user|has_plan:'drilldown' %}
<a class="navbar-item" href="{% url 'insights' %}"> <a class="navbar-item" href="{% url 'insights' %}">
Insights Insights
</a> </a>
{% endif %} {% endif %}
{% endif %}
<a class="navbar-item add-button"> <a class="navbar-item add-button">
Install Install
</a> </a>

View File

@ -47,7 +47,7 @@
{% csrf_token %} {% csrf_token %}
<div class="field has-addons"> <div class="field has-addons">
<div class="control is-expanded has-icons-left"> <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"> <span class="icon is-small is-left">
<i class="fas fa-magnifying-glass"></i> <i class="fas fa-magnifying-glass"></i>
</span> </span>

View File

@ -33,7 +33,10 @@ class InsightsSearch(LoginRequiredMixin, PermissionRequiredMixin, View):
permission_required = "use_insights" permission_required = "use_insights"
def post(self, request): 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: if not context:
return HttpResponseForbidden() return HttpResponseForbidden()
return render(request, self.template_name, context) return render(request, self.template_name, context)