diff --git a/app/urls.py b/app/urls.py index 60053c7..b837317 100644 --- a/app/urls.py +++ b/app/urls.py @@ -40,6 +40,7 @@ from core.views.manage.threshold.irc import ( ThresholdIRCNetworkInfo, ThresholdIRCNetworkInfoEdit, ThresholdIRCNetworkRelayDel, + ThresholdIRCNetworkRelayProvision, ThresholdIRCNetworkRelays, ThresholdIRCNetworkRelayStatus, ThresholdIRCNetworks, @@ -137,6 +138,11 @@ urlpatterns = [ ThresholdIRCActionsRegistration.as_view(), name="threshold_irc_actions_registration_net", ), + path( + "manage/threshold/irc/network///provision/", + ThresholdIRCNetworkRelayProvision.as_view(), + name="threshold_irc_network_relay_provision", + ), path( "manage/threshold/irc/actions/registration/", ThresholdIRCActionsRegistration.as_view(), diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 99d3303..1aea1e1 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -234,3 +234,10 @@ def irc_confirm_accounts(tokens): payload = tokens updated = threshold_request(url, payload, method="PUT") return updated + + +def irc_provision_relay(net, num): + url = f"irc/network/{net}/{num}/provision" + payload = {} + provisioned = threshold_request(url, payload, method="POST") + return provisioned diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index 135eea6..606e9a6 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -105,6 +105,18 @@ +
+ +
diff --git a/core/views/manage/threshold/irc.py b/core/views/manage/threshold/irc.py index b39f45f..a770ee1 100644 --- a/core/views/manage/threshold/irc.py +++ b/core/views/manage/threshold/irc.py @@ -133,6 +133,31 @@ class ThresholdIRCNetworkRelayDel(SuperUserRequiredMixin, APIView): return render(request, self.template_name, context) +class ThresholdIRCNetworkRelayProvision(SuperUserRequiredMixin, APIView): + template_name = "manage/threshold/irc/network/relays.html" + + def post(self, request, net, num): + """ + Provision a relay + """ + provisioned = threshold.irc_provision_relay(net, num) + if provisioned["success"]: + + message = f"Provisioned relay {num}" + message_class = "success" + else: + message = provisioned["reason"] + message_class = "danger" + relays = threshold.get_irc_relays(net) + context = { + "net": net, + "message": message, + "class": message_class, + "relays": relays["relays"], + } + return render(request, self.template_name, context) + + class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView): template_name = "manage/threshold/irc/network/relays.html" diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py index 488e5cb..f8c9357 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -260,8 +260,6 @@ class DrilldownContextModal(APIView): query_params["mtype"] = None if request.user.is_superuser: if query_params["type"] in ["query", "notice"]: - print("BOT NICK", query_params["channel"]) - print("QUERY NICK", query_params["nick"]) nicks = [query_params["channel"], query_params["nick"]] query_params["sorting"] = "desc" if (