|
|
@ -1,8 +1,10 @@
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
|
|
|
|
import urllib
|
|
|
|
|
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
from django.conf import settings
|
|
|
|
from django.http import HttpResponse, JsonResponse
|
|
|
|
from django.http import HttpResponse, JsonResponse
|
|
|
|
from django.shortcuts import render
|
|
|
|
from django.shortcuts import render
|
|
|
|
|
|
|
|
from django.urls import reverse
|
|
|
|
from django.views import View
|
|
|
|
from django.views import View
|
|
|
|
from django_tables2 import SingleTableMixin
|
|
|
|
from django_tables2 import SingleTableMixin
|
|
|
|
from rest_framework.parsers import FormParser
|
|
|
|
from rest_framework.parsers import FormParser
|
|
|
@ -49,8 +51,6 @@ class Drilldown(View):
|
|
|
|
plan_name = "drilldown"
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
def get(self, request):
|
|
|
|
# if not request.user.has_plan(self.plan_name):
|
|
|
|
|
|
|
|
# return render(request, "denied.html")
|
|
|
|
|
|
|
|
if request.user.is_anonymous:
|
|
|
|
if request.user.is_anonymous:
|
|
|
|
sizes = settings.OPENSEARCH_MAIN_SIZES_ANON
|
|
|
|
sizes = settings.OPENSEARCH_MAIN_SIZES_ANON
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -60,16 +60,15 @@ class Drilldown(View):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DrilldownSearch(View):
|
|
|
|
|
|
|
|
# parser_classes = [JSONParser]
|
|
|
|
|
|
|
|
template_name = "ui/drilldown/results.html"
|
|
|
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
def post(self, request):
|
|
|
|
# if not request.user.has_plan(self.plan_name):
|
|
|
|
template_name = "ui/drilldown/results.html"
|
|
|
|
# return HttpResponseForbidden()
|
|
|
|
data_args = request.POST.dict()
|
|
|
|
|
|
|
|
del data_args["csrfmiddlewaretoken"]
|
|
|
|
|
|
|
|
print("rep", repr(data_args["dates"]))
|
|
|
|
|
|
|
|
if data_args["dates"] == " - ":
|
|
|
|
|
|
|
|
del data_args["dates"]
|
|
|
|
|
|
|
|
url_params = urllib.parse.urlencode(data_args)
|
|
|
|
|
|
|
|
print("url_params", url_params)
|
|
|
|
context = query_results(request)
|
|
|
|
context = query_results(request)
|
|
|
|
if "message" in context:
|
|
|
|
if "message" in context:
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
return render(request, self.template_name, context)
|
|
|
@ -86,7 +85,9 @@ class DrilldownSearch(View):
|
|
|
|
]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if context:
|
|
|
|
if context:
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
response = render(request, template_name, context)
|
|
|
|
|
|
|
|
response["HX-Push"] = reverse("home") + "?" + url_params
|
|
|
|
|
|
|
|
return response
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return HttpResponse("No results")
|
|
|
|
return HttpResponse("No results")
|
|
|
|
|
|
|
|
|
|
|
|