|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
from ast import literal_eval
|
|
|
|
|
|
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
|
|
|
|
|
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
|
|
|
|
|
from django.shortcuts import render
|
|
|
|
|
from django.views import View
|
|
|
|
@ -19,38 +19,32 @@ from core.lib.threshold import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Insights(LoginRequiredMixin, View):
|
|
|
|
|
class Insights(LoginRequiredMixin, PermissionRequiredMixin, View):
|
|
|
|
|
template_name = "ui/insights/insights.html"
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
permission_required = "use_insights"
|
|
|
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
|
if not request.user.has_plan(self.plan_name):
|
|
|
|
|
return render(request, "denied.html")
|
|
|
|
|
return render(request, self.template_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsightsSearch(LoginRequiredMixin, View):
|
|
|
|
|
class InsightsSearch(LoginRequiredMixin, PermissionRequiredMixin, View):
|
|
|
|
|
# parser_classes = [JSONParser]
|
|
|
|
|
template_name = "ui/insights/info.html"
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
permission_required = "use_insights"
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
|
if not request.user.has_plan(self.plan_name):
|
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
|
context = query_single_result(request)
|
|
|
|
|
if not context:
|
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsightsChannels(LoginRequiredMixin, APIView):
|
|
|
|
|
class InsightsChannels(LoginRequiredMixin, PermissionRequiredMixin, APIView):
|
|
|
|
|
parser_classes = [FormParser]
|
|
|
|
|
template_name = "ui/insights/channels.html"
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
permission_required = "use_insights"
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
|
if not request.user.has_plan(self.plan_name):
|
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
|
if "net" not in request.data:
|
|
|
|
|
return HttpResponse("No net")
|
|
|
|
|
if "nick" not in request.data:
|
|
|
|
@ -65,14 +59,12 @@ class InsightsChannels(LoginRequiredMixin, APIView):
|
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsightsNicks(LoginRequiredMixin, APIView):
|
|
|
|
|
class InsightsNicks(LoginRequiredMixin, PermissionRequiredMixin, APIView):
|
|
|
|
|
parser_classes = [FormParser]
|
|
|
|
|
template_name = "ui/insights/nicks.html"
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
permission_required = "use_insights"
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
|
if not request.user.has_plan(self.plan_name):
|
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
|
if "net" not in request.data:
|
|
|
|
|
return HttpResponse("No net")
|
|
|
|
|
if "nick" not in request.data:
|
|
|
|
@ -91,14 +83,12 @@ class InsightsNicks(LoginRequiredMixin, APIView):
|
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsightsMeta(LoginRequiredMixin, APIView):
|
|
|
|
|
class InsightsMeta(LoginRequiredMixin, PermissionRequiredMixin, APIView):
|
|
|
|
|
parser_classes = [FormParser]
|
|
|
|
|
template_name = "ui/insights/meta.html"
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
permission_required = "use_insights"
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
|
if not request.user.has_plan(self.plan_name):
|
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
|
if "net" not in request.data:
|
|
|
|
|
return HttpResponse("No net")
|
|
|
|
|
if "nicks" not in request.data:
|
|
|
|
@ -133,14 +123,12 @@ class InsightsMeta(LoginRequiredMixin, APIView):
|
|
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsightsInfoModal(LoginRequiredMixin, APIView):
|
|
|
|
|
class InsightsInfoModal(LoginRequiredMixin, PermissionRequiredMixin, APIView):
|
|
|
|
|
parser_classes = [FormParser]
|
|
|
|
|
plan_name = "drilldown"
|
|
|
|
|
template_name = "modals/drilldown.html"
|
|
|
|
|
permission_required = "use_insights"
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
|
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:
|
|
|
|
|