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 = [
path("", Home.as_view(), name="home"),
path("", Drilldown.as_view(), name="home"),
path("callback", Callback.as_view(), name="callback"),
path("billing/", Billing.as_view(), name="billing"),
path("order/<str:plan_name>/", Order.as_view(), name="order"),

View File

@ -93,6 +93,10 @@ def filter_blacklisted(user, response):
if blacklisted_item in str(content):
# Remove the item
if item in response["hits"]["hits"]:
# Anonymous
if not user:
response["hits"]["hits"].remove(item)
else:
if not user.is_superuser:
response["hits"]["hits"].remove(item)
# Let the UI know something was redacted
@ -136,9 +140,13 @@ def query_results(request, size=None):
return False
if "query" in request.POST:
query = request.POST["query"]
if hasattr(request, "user"):
user = request.user
else:
user = None
results = run_main_query(
client,
request.user,
user,
query,
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"
plan_name = "drilldown"
def get(self, request):
if not request.user.has_plan(self.plan_name):
return render(request, "denied.html")
#if not request.user.has_plan(self.plan_name):
# return render(request, "denied.html")
context = {
"sizes": settings.OPENSEARCH_MAIN_SIZES,
}
return render(request, self.template_name, context)
class DrilldownSearch(LoginRequiredMixin, View):
class DrilldownSearch(View):
# parser_classes = [JSONParser]
template_name = "ui/drilldown/results.html"
plan_name = "drilldown"
def post(self, request):
if not request.user.has_plan(self.plan_name):
return HttpResponseForbidden()
#if not request.user.has_plan(self.plan_name):
# return HttpResponseForbidden()
context = query_results(request)
if not context:
@ -59,14 +59,14 @@ class DrilldownSearch(LoginRequiredMixin, View):
return HttpResponse("No results")
class ThresholdInfoModal(LoginRequiredMixin, APIView):
class ThresholdInfoModal(APIView):
parser_classes = [FormParser]
plan_name = "drilldown"
template_name = "modals/drilldown.html"
def post(self, request):
if not request.user.has_plan(self.plan_name):
return JsonResponse({"success": False})
#if not request.user.has_plan(self.plan_name):
# return JsonResponse({"success": False})
if "net" not in request.data:
return JsonResponse({"success": False})
if "nick" not in request.data: