diff --git a/app/urls.py b/app/urls.py index 68cb375..c78d05a 100644 --- a/app/urls.py +++ b/app/urls.py @@ -26,10 +26,11 @@ from core.views.callbacks import Callback from core.views.manage.threshold.irc import ( ThresholdIRCAliases, ThresholdIRCNetworkActions, - ThresholdIRCNetworkActionsAddRelay, + ThresholdIRCNetworkActionsRelay, ThresholdIRCNetworkChannels, ThresholdIRCNetworkInfo, ThresholdIRCNetworkInfoEdit, + ThresholdIRCNetworkRelayDel, ThresholdIRCNetworkRelays, ThresholdIRCNetworkRelayStatus, ThresholdIRCNetworks, @@ -123,6 +124,11 @@ urlpatterns = [ ThresholdIRCNetworkRelays.as_view(), name="threshold_irc_network_relays", ), + path( + "manage/threshold/irc/network///", + ThresholdIRCNetworkRelayDel.as_view(), + name="threshold_irc_network_relay_del", + ), path( "manage/threshold/irc/network////", ThresholdIRCNetworkRelayStatus.as_view(), @@ -156,7 +162,7 @@ urlpatterns = [ ), path( "manage/threshold/irc/network/actions//", - ThresholdIRCNetworkActionsAddRelay.as_view(), + ThresholdIRCNetworkActionsRelay.as_view(), name="threshold_irc_network_actions_add_relay", ), ## diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 11a67a1..74872e3 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -94,3 +94,10 @@ def add_relay(net, num): payload = {} created = threshold_request(url, payload, method="PUT") return created + + +def del_relay(net, num): + url = f"irc/network/{net}/{num}" + payload = {} + deleted = threshold_request(url, payload, method="DELETE") + return deleted diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index 1b788ec..ff55933 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -65,6 +65,16 @@ {% endif %} + {{ relay.chans }} diff --git a/core/views/manage/threshold/irc.py b/core/views/manage/threshold/irc.py index afe75b2..a56a70b 100644 --- a/core/views/manage/threshold/irc.py +++ b/core/views/manage/threshold/irc.py @@ -80,6 +80,31 @@ class ThresholdIRCNetworkRelays(SuperUserRequiredMixin, View): return render(request, self.template_name, context) +class ThresholdIRCNetworkRelayDel(SuperUserRequiredMixin, APIView): + template_name = "manage/threshold/irc/network/relays.html" + + def delete(self, request, net, num): + """ + Delete a relay + """ + deleted = threshold.del_relay(net, num) + if deleted["success"]: + + message = f"Deleted relay {num}" + message_class = "success" + else: + message = deleted["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" @@ -159,7 +184,6 @@ class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, APIView): else: channel = request.data["channel"] joined = threshold.join_channel(net, channel) - print("JOINED", joined) if joined["success"]: message = f"Requested join on relay: {joined['relays']}" message_class = "success" @@ -202,7 +226,7 @@ class ThresholdIRCNetworkActions(SuperUserRequiredMixin, View): return render(request, self.template_name, context) -class ThresholdIRCNetworkActionsAddRelay(SuperUserRequiredMixin, APIView): +class ThresholdIRCNetworkActionsRelay(SuperUserRequiredMixin, APIView): template_name = "manage/threshold/irc/network/actions.html" parser_classes = [FormParser] @@ -210,7 +234,6 @@ class ThresholdIRCNetworkActionsAddRelay(SuperUserRequiredMixin, APIView): """ Create a relay """ - print("ACTION PUT", request.data, net) if "num" not in request.data: message = "No num specified" message_class = "danger" @@ -222,7 +245,6 @@ class ThresholdIRCNetworkActionsAddRelay(SuperUserRequiredMixin, APIView): else: num = int(num) created = threshold.add_relay(net, num) - print("CREATED", created) if created["success"]: id = created["id"] alias = created["alias"]