From 81708ef490a95791f8da7a0036678a32155ace60 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 14 Aug 2022 00:01:00 +0100 Subject: [PATCH] Add API channel deletion endpoint --- app/urls.py | 6 ++ core/lib/manage/threshold.py | 5 +- .../threshold/irc/network/channels.html | 5 +- core/views/manage/threshold/irc.py | 57 ++++++++++++++++++- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/app/urls.py b/app/urls.py index 2a7d6f0..91d7c3a 100644 --- a/app/urls.py +++ b/app/urls.py @@ -48,6 +48,7 @@ from core.views.manage.threshold.irc import ( ThresholdIRCOverviewAlerts, ThresholdIRCSendMessage, ThresholdIRCStats, + ThresholdIRCNetworkChannelsAPI, ) # Management stuff @@ -199,6 +200,11 @@ urlpatterns = [ ThresholdIRCNetworkChannels.as_view(), name="threshold_irc_network_channels", ), + path( + "manage/threshold/irc/network//channel/json/", + ThresholdIRCNetworkChannelsAPI.as_view(), + name="threshold_irc_network_channel_json", + ), path( "manage/threshold/irc/network//channel//", ThresholdIRCNetworkChannels.as_view(), diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index c2a4fc6..04afc0a 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -66,9 +66,8 @@ def get_irc_channels(net): def part_channel(net, channel): - channel = urllib.parse.quote(channel, safe="") - url = f"irc/network/{net}/channel/{channel}" - payload = {} + url = f"irc/network/{net}/channel" + payload = {"channel": channel} parted = threshold_request(url, payload, method="DELETE") if not parted: return {} diff --git a/core/templates/manage/threshold/irc/network/channels.html b/core/templates/manage/threshold/irc/network/channels.html index 5a95818..f87db4c 100644 --- a/core/templates/manage/threshold/irc/network/channels.html +++ b/core/templates/manage/threshold/irc/network/channels.html @@ -23,8 +23,9 @@