Make Drilldown public

This commit is contained in:
Mark Veidemanis 2022-08-02 22:22:22 +01:00
parent fa2bfdecdd
commit b323ea2ae2
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 20 additions and 12 deletions

View File

@ -61,7 +61,7 @@ from core.views.ui.insights import (
) )
urlpatterns = [ urlpatterns = [
path("", Home.as_view(), name="home"), path("", Drilldown.as_view(), name="home"),
path("callback", Callback.as_view(), name="callback"), path("callback", Callback.as_view(), name="callback"),
path("billing/", Billing.as_view(), name="billing"), path("billing/", Billing.as_view(), name="billing"),
path("order/<str:plan_name>/", Order.as_view(), name="order"), path("order/<str:plan_name>/", Order.as_view(), name="order"),

View File

@ -93,8 +93,12 @@ def filter_blacklisted(user, response):
if blacklisted_item in str(content): if blacklisted_item in str(content):
# Remove the item # Remove the item
if item in response["hits"]["hits"]: if item in response["hits"]["hits"]:
if not user.is_superuser: # Anonymous
if not user:
response["hits"]["hits"].remove(item) response["hits"]["hits"].remove(item)
else:
if not user.is_superuser:
response["hits"]["hits"].remove(item)
# Let the UI know something was redacted # Let the UI know something was redacted
response["redacted"] += 1 response["redacted"] += 1
response["exemption"] = True response["exemption"] = True
@ -136,9 +140,13 @@ def query_results(request, size=None):
return False return False
if "query" in request.POST: if "query" in request.POST:
query = request.POST["query"] query = request.POST["query"]
if hasattr(request, "user"):
user = request.user
else:
user = None
results = run_main_query( results = run_main_query(
client, client,
request.user, user,
query, query,
size=size, size=size,
) )

View File

@ -17,27 +17,27 @@ from core.lib.threshold import (
) )
class Drilldown(LoginRequiredMixin, View): class Drilldown(View):
template_name = "ui/drilldown/drilldown.html" template_name = "ui/drilldown/drilldown.html"
plan_name = "drilldown" plan_name = "drilldown"
def get(self, request): def get(self, request):
if not request.user.has_plan(self.plan_name): #if not request.user.has_plan(self.plan_name):
return render(request, "denied.html") # return render(request, "denied.html")
context = { context = {
"sizes": settings.OPENSEARCH_MAIN_SIZES, "sizes": settings.OPENSEARCH_MAIN_SIZES,
} }
return render(request, self.template_name, context) return render(request, self.template_name, context)
class DrilldownSearch(LoginRequiredMixin, View): class DrilldownSearch(View):
# parser_classes = [JSONParser] # parser_classes = [JSONParser]
template_name = "ui/drilldown/results.html" template_name = "ui/drilldown/results.html"
plan_name = "drilldown" plan_name = "drilldown"
def post(self, request): def post(self, request):
if not request.user.has_plan(self.plan_name): #if not request.user.has_plan(self.plan_name):
return HttpResponseForbidden() # return HttpResponseForbidden()
context = query_results(request) context = query_results(request)
if not context: if not context:
@ -59,14 +59,14 @@ class DrilldownSearch(LoginRequiredMixin, View):
return HttpResponse("No results") return HttpResponse("No results")
class ThresholdInfoModal(LoginRequiredMixin, APIView): class ThresholdInfoModal(APIView):
parser_classes = [FormParser] parser_classes = [FormParser]
plan_name = "drilldown" plan_name = "drilldown"
template_name = "modals/drilldown.html" template_name = "modals/drilldown.html"
def post(self, request): def post(self, request):
if not request.user.has_plan(self.plan_name): #if not request.user.has_plan(self.plan_name):
return JsonResponse({"success": False}) # return JsonResponse({"success": False})
if "net" not in request.data: if "net" not in request.data:
return JsonResponse({"success": False}) return JsonResponse({"success": False})
if "nick" not in request.data: if "nick" not in request.data: