Refactor code into fewer files, removing dynamic folders
This commit is contained in:
parent
da235fedd6
commit
3d91c4164e
32
app/urls.py
32
app/urls.py
|
@ -21,23 +21,9 @@ from django.views.generic import TemplateView
|
||||||
|
|
||||||
# Threshold API stuff
|
# Threshold API stuff
|
||||||
from core.api.views.threshold import ThresholdChans, ThresholdOnline, ThresholdUsers
|
from core.api.views.threshold import ThresholdChans, ThresholdOnline, ThresholdUsers
|
||||||
|
|
||||||
# Main tool pages
|
|
||||||
from core.ui.views.drilldown import Drilldown
|
|
||||||
from core.ui.views.insights import Insights
|
|
||||||
from core.views import Billing, Cancel, Home, Order, Portal, Signup
|
from core.views import Billing, Cancel, Home, Order, Portal, Signup
|
||||||
from core.views.callbacks import Callback
|
from core.views.callbacks import Callback
|
||||||
|
from core.views.manage.threshold.irc import (
|
||||||
# Dynamic elements
|
|
||||||
from core.views.dynamic.drilldown import DrilldownSearch, ThresholdInfoModal
|
|
||||||
from core.views.dynamic.insights import (
|
|
||||||
InsightsChannels,
|
|
||||||
InsightsInfoModal,
|
|
||||||
InsightsMeta,
|
|
||||||
InsightsNicks,
|
|
||||||
InsightsSearch,
|
|
||||||
)
|
|
||||||
from core.views.dynamic.manage.threshold.irc import (
|
|
||||||
ThresholdIRCNetworkChannels,
|
ThresholdIRCNetworkChannels,
|
||||||
ThresholdIRCNetworkInfo,
|
ThresholdIRCNetworkInfo,
|
||||||
ThresholdIRCNetworkInfoEdit,
|
ThresholdIRCNetworkInfoEdit,
|
||||||
|
@ -47,7 +33,21 @@ from core.views.dynamic.manage.threshold.irc import (
|
||||||
)
|
)
|
||||||
|
|
||||||
# Management stuff
|
# Management stuff
|
||||||
from core.views.manage.threshold import ThresholdIRCNetwork, ThresholdIRCOverview
|
from core.views.manage.threshold.threshold import (
|
||||||
|
ThresholdIRCNetwork,
|
||||||
|
ThresholdIRCOverview,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Main tool pages
|
||||||
|
from core.views.ui.drilldown import Drilldown, DrilldownSearch, ThresholdInfoModal
|
||||||
|
from core.views.ui.insights import (
|
||||||
|
Insights,
|
||||||
|
InsightsChannels,
|
||||||
|
InsightsInfoModal,
|
||||||
|
InsightsMeta,
|
||||||
|
InsightsNicks,
|
||||||
|
InsightsSearch,
|
||||||
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", Home.as_view(), name="home"),
|
path("", Home.as_view(), name="home"),
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
from django.conf import settings
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.views import View
|
|
||||||
|
|
||||||
|
|
||||||
class Drilldown(LoginRequiredMixin, 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")
|
|
||||||
context = {
|
|
||||||
"sizes": settings.OPENSEARCH_MAIN_SIZES,
|
|
||||||
}
|
|
||||||
return render(request, self.template_name, context)
|
|
|
@ -1,13 +0,0 @@
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.views import View
|
|
||||||
|
|
||||||
|
|
||||||
class Insights(LoginRequiredMixin, View):
|
|
||||||
template_name = "ui/insights/insights.html"
|
|
||||||
plan_name = "drilldown"
|
|
||||||
|
|
||||||
def get(self, request):
|
|
||||||
if not request.user.has_plan(self.plan_name):
|
|
||||||
return render(request, "denied.html")
|
|
||||||
return render(request, self.template_name)
|
|
|
@ -15,7 +15,7 @@ from core.views.manage.permissions import SuperUserRequiredMixin
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCStats(SuperUserRequiredMixin, View):
|
class ThresholdIRCStats(SuperUserRequiredMixin, View):
|
||||||
stats_template = "dynamic/manage/threshold/irc/overview/stats.html"
|
stats_template = "manage/threshold/irc/overview/stats.html"
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
stats = get_irc_stats()
|
stats = get_irc_stats()
|
||||||
|
@ -24,7 +24,7 @@ class ThresholdIRCStats(SuperUserRequiredMixin, View):
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworks(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetworks(SuperUserRequiredMixin, View):
|
||||||
template_name = "dynamic/manage/threshold/irc/overview/networks.html"
|
template_name = "manage/threshold/irc/overview/networks.html"
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
networks = get_irc_networks()
|
networks = get_irc_networks()
|
||||||
|
@ -33,7 +33,7 @@ class ThresholdIRCNetworks(SuperUserRequiredMixin, View):
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View):
|
||||||
template_name = "dynamic/manage/threshold/irc/network/info.html"
|
template_name = "manage/threshold/irc/network/info.html"
|
||||||
|
|
||||||
def post(self, request, net):
|
def post(self, request, net):
|
||||||
network = get_irc_network(net)
|
network = get_irc_network(net)
|
||||||
|
@ -42,7 +42,7 @@ class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View):
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkInfoEdit(SuperUserRequiredMixin, APIView):
|
class ThresholdIRCNetworkInfoEdit(SuperUserRequiredMixin, APIView):
|
||||||
template_name = "dynamic/manage/threshold/irc/network/edit-network.html"
|
template_name = "manage/threshold/irc/network/edit-network.html"
|
||||||
parser_classes = [FormParser]
|
parser_classes = [FormParser]
|
||||||
|
|
||||||
def get(self, request, net):
|
def get(self, request, net):
|
||||||
|
@ -62,7 +62,7 @@ class ThresholdIRCNetworkInfoEdit(SuperUserRequiredMixin, APIView):
|
||||||
Actually edit the network.
|
Actually edit the network.
|
||||||
Returns the info pane with a message about the success.
|
Returns the info pane with a message about the success.
|
||||||
"""
|
"""
|
||||||
template_name = "dynamic/manage/threshold/irc/network/info.html"
|
template_name = "manage/threshold/irc/network/info.html"
|
||||||
edited = edit_irc_network(net, request.data)
|
edited = edit_irc_network(net, request.data)
|
||||||
if edited["success"]:
|
if edited["success"]:
|
||||||
message = "Successfully edited!"
|
message = "Successfully edited!"
|
||||||
|
@ -79,7 +79,7 @@ class ThresholdIRCNetworkInfoEdit(SuperUserRequiredMixin, APIView):
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkRelays(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetworkRelays(SuperUserRequiredMixin, View):
|
||||||
template_name = "dynamic/manage/threshold/irc/network/relays.html"
|
template_name = "manage/threshold/irc/network/relays.html"
|
||||||
|
|
||||||
def post(self, request, net):
|
def post(self, request, net):
|
||||||
relays = get_irc_relays(net)
|
relays = get_irc_relays(net)
|
||||||
|
@ -88,7 +88,7 @@ class ThresholdIRCNetworkRelays(SuperUserRequiredMixin, View):
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, View):
|
||||||
template_name = "dynamic/manage/threshold/irc/network/channels.html"
|
template_name = "manage/threshold/irc/network/channels.html"
|
||||||
|
|
||||||
def post(self, request, net):
|
def post(self, request, net):
|
||||||
channels = get_irc_channels(net)
|
channels = get_irc_channels(net)
|
|
@ -5,14 +5,14 @@ from core.views.manage.permissions import SuperUserRequiredMixin
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCOverview(SuperUserRequiredMixin, View):
|
class ThresholdIRCOverview(SuperUserRequiredMixin, View):
|
||||||
template_name = "manage/threshold/irc/overview.html"
|
template_name = "manage/threshold/irc/overview/overview.html"
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
return render(request, self.template_name)
|
return render(request, self.template_name)
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetwork(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetwork(SuperUserRequiredMixin, View):
|
||||||
template_name = "manage/threshold/irc/network.html"
|
template_name = "manage/threshold/irc/network/network.html"
|
||||||
|
|
||||||
def get(self, request, net):
|
def get(self, request, net):
|
||||||
context = {"net": net}
|
context = {"net": net}
|
|
@ -1,13 +1,14 @@
|
||||||
import json
|
from django.conf import settings
|
||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
|
||||||
from rest_framework.parsers import FormParser
|
from rest_framework.parsers import FormParser
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
import json
|
||||||
from core.lib.opensearch import query_results
|
from core.lib.opensearch import query_results
|
||||||
|
|
||||||
|
|
||||||
from core.lib.threshold import (
|
from core.lib.threshold import (
|
||||||
annotate_num_chans,
|
annotate_num_chans,
|
||||||
annotate_num_users,
|
annotate_num_users,
|
||||||
|
@ -15,6 +16,17 @@ from core.lib.threshold import (
|
||||||
get_users,
|
get_users,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Drilldown(LoginRequiredMixin, 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")
|
||||||
|
context = {
|
||||||
|
"sizes": settings.OPENSEARCH_MAIN_SIZES,
|
||||||
|
}
|
||||||
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
class DrilldownSearch(LoginRequiredMixin, View):
|
class DrilldownSearch(LoginRequiredMixin, View):
|
||||||
# parser_classes = [JSONParser]
|
# parser_classes = [JSONParser]
|
|
@ -1,12 +1,10 @@
|
||||||
from ast import literal_eval
|
|
||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from rest_framework.parsers import FormParser
|
from rest_framework.parsers import FormParser
|
||||||
from rest_framework.views import APIView
|
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
|
||||||
|
|
||||||
|
from rest_framework.views import APIView
|
||||||
from core.lib.meta import get_meta
|
from core.lib.meta import get_meta
|
||||||
from core.lib.nicktrace import get_nicks
|
from core.lib.nicktrace import get_nicks
|
||||||
from core.lib.opensearch import query_single_result
|
from core.lib.opensearch import query_single_result
|
||||||
|
@ -17,8 +15,18 @@ from core.lib.threshold import (
|
||||||
get_chans,
|
get_chans,
|
||||||
get_users,
|
get_users,
|
||||||
)
|
)
|
||||||
|
from ast import literal_eval
|
||||||
|
|
||||||
|
|
||||||
|
class Insights(LoginRequiredMixin, View):
|
||||||
|
template_name = "ui/insights/insights.html"
|
||||||
|
plan_name = "drilldown"
|
||||||
|
|
||||||
|
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, View):
|
||||||
# parser_classes = [JSONParser]
|
# parser_classes = [JSONParser]
|
||||||
template_name = "ui/insights/info.html"
|
template_name = "ui/insights/info.html"
|
Loading…
Reference in New Issue