|
|
@ -243,41 +243,29 @@ class DrilldownContextModal(APIView):
|
|
|
|
if request.resolver_match.url_name == "modal_context_table":
|
|
|
|
if request.resolver_match.url_name == "modal_context_table":
|
|
|
|
print("POST CONTEXT TABLE")
|
|
|
|
print("POST CONTEXT TABLE")
|
|
|
|
self.template_name = "modals/context_table.html"
|
|
|
|
self.template_name = "modals/context_table.html"
|
|
|
|
# if not request.user.has_plan(self.plan_name):
|
|
|
|
|
|
|
|
# return JsonResponse({"success": False})
|
|
|
|
|
|
|
|
num = None
|
|
|
|
|
|
|
|
index = "main"
|
|
|
|
|
|
|
|
size = 20
|
|
|
|
size = 20
|
|
|
|
# Check right fields exist
|
|
|
|
|
|
|
|
if "net" not in request.data:
|
|
|
|
|
|
|
|
return JsonResponse({"success": False})
|
|
|
|
|
|
|
|
if "channel" not in request.data:
|
|
|
|
|
|
|
|
return JsonResponse({"success": False})
|
|
|
|
|
|
|
|
if "src" not in request.data:
|
|
|
|
|
|
|
|
return JsonResponse({"success": False})
|
|
|
|
|
|
|
|
if "time" not in request.data:
|
|
|
|
|
|
|
|
return JsonResponse({"success": False})
|
|
|
|
|
|
|
|
if "date" not in request.data:
|
|
|
|
|
|
|
|
return JsonResponse({"success": False})
|
|
|
|
|
|
|
|
if "num" in request.data:
|
|
|
|
|
|
|
|
if request.data["num"]:
|
|
|
|
|
|
|
|
if not request.data["num"] == "—":
|
|
|
|
|
|
|
|
num = request.data["num"]
|
|
|
|
|
|
|
|
if "index" in request.data:
|
|
|
|
|
|
|
|
if request.data["index"]:
|
|
|
|
|
|
|
|
index = request.data["index"]
|
|
|
|
|
|
|
|
net = request.data["net"]
|
|
|
|
|
|
|
|
channel = request.data["channel"]
|
|
|
|
|
|
|
|
# Create the query params from the POST arguments
|
|
|
|
# Create the query params from the POST arguments
|
|
|
|
blacklisted = ["date", "time"]
|
|
|
|
mandatory = ["net", "channel", "num", "src", "index"]
|
|
|
|
query_params = {
|
|
|
|
invalid = [None, False, "—", "None"]
|
|
|
|
k: v for k, v in request.data.items() if v and k not in blacklisted
|
|
|
|
query_params = {k: v for k, v in request.data.items() if v}
|
|
|
|
}
|
|
|
|
for key in query_params:
|
|
|
|
|
|
|
|
if query_params[key] in invalid:
|
|
|
|
|
|
|
|
query_params[key] = None
|
|
|
|
|
|
|
|
for key in mandatory:
|
|
|
|
|
|
|
|
if key not in query_params:
|
|
|
|
|
|
|
|
query_params[key] = None
|
|
|
|
query_params["sorting"] = "desc"
|
|
|
|
query_params["sorting"] = "desc"
|
|
|
|
|
|
|
|
|
|
|
|
# Create the query with the context helper
|
|
|
|
# Create the query with the context helper
|
|
|
|
search_query = construct_query(net, channel, request.data["src"], num, size)
|
|
|
|
search_query = construct_query(
|
|
|
|
print("SEARCH QUERY", search_query)
|
|
|
|
query_params["index"],
|
|
|
|
|
|
|
|
query_params["net"],
|
|
|
|
|
|
|
|
query_params["channel"],
|
|
|
|
|
|
|
|
query_params["src"],
|
|
|
|
|
|
|
|
query_params["num"],
|
|
|
|
|
|
|
|
size,
|
|
|
|
|
|
|
|
)
|
|
|
|
results = query_results(
|
|
|
|
results = query_results(
|
|
|
|
request, query_params, annotate=True, custom_query=search_query
|
|
|
|
request, query_params, annotate=True, custom_query=search_query
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -290,19 +278,18 @@ class DrilldownContextModal(APIView):
|
|
|
|
# results["object_list"][index]["time"] = item["time"]+"SSS"
|
|
|
|
# results["object_list"][index]["time"] = item["time"]+"SSS"
|
|
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
context = {
|
|
|
|
"net": net,
|
|
|
|
"net": query_params["net"],
|
|
|
|
"channel": channel,
|
|
|
|
"channel": query_params["channel"],
|
|
|
|
"src": request.data["src"],
|
|
|
|
"src": query_params["src"],
|
|
|
|
"ts": f"{request.data['date']} {request.data['time']}",
|
|
|
|
"ts": f"{query_params['date']} {query_params['time']}",
|
|
|
|
"object_list": results["object_list"],
|
|
|
|
"object_list": results["object_list"],
|
|
|
|
"time": request.data["time"],
|
|
|
|
"time": query_params["time"],
|
|
|
|
"date": request.data["date"],
|
|
|
|
"date": query_params["date"],
|
|
|
|
"index": request.data["date"],
|
|
|
|
"index": query_params["index"],
|
|
|
|
|
|
|
|
"num": query_params["num"],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if index:
|
|
|
|
print("CONTEXT", context)
|
|
|
|
context["index"] = index
|
|
|
|
|
|
|
|
if num:
|
|
|
|
|
|
|
|
context["num"] = num
|
|
|
|
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|