From 69b4cb88655c492b8fae1652c49f94bb070bc674 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 14 Aug 2022 09:24:21 +0100 Subject: [PATCH] Fix authed variable and switch join/part API to use JSON --- app/urls.py | 2 +- core/lib/manage/threshold.py | 5 ++--- core/templates/manage/threshold/irc/network/relays.html | 2 +- core/views/manage/threshold/irc.py | 5 +++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/urls.py b/app/urls.py index 91d7c3a..0cf05b9 100644 --- a/app/urls.py +++ b/app/urls.py @@ -36,6 +36,7 @@ from core.views.manage.threshold.irc import ( ThresholdIRCNetworkActionsAuto, ThresholdIRCNetworkActionsRelay, ThresholdIRCNetworkChannels, + ThresholdIRCNetworkChannelsAPI, ThresholdIRCNetworkDel, ThresholdIRCNetworkInfo, ThresholdIRCNetworkInfoEdit, @@ -48,7 +49,6 @@ from core.views.manage.threshold.irc import ( ThresholdIRCOverviewAlerts, ThresholdIRCSendMessage, ThresholdIRCStats, - ThresholdIRCNetworkChannelsAPI, ) # Management stuff diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 04afc0a..5671e95 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -75,9 +75,8 @@ def part_channel(net, channel): def join_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} joined = threshold_request(url, payload, method="PUT") if not joined: return {} diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index b88f904..e75066b 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -44,7 +44,7 @@ {% endif %} - {% if relay.authenticated %} + {% if relay.authed %} diff --git a/core/views/manage/threshold/irc.py b/core/views/manage/threshold/irc.py index 994024c..b5fa024 100644 --- a/core/views/manage/threshold/irc.py +++ b/core/views/manage/threshold/irc.py @@ -1,6 +1,6 @@ from django.shortcuts import render from django.views import View -from rest_framework.parsers import FormParser, JSONParser +from rest_framework.parsers import FormParser from rest_framework.views import APIView from core.lib.manage import threshold @@ -208,6 +208,7 @@ class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView): } return render(request, self.template_name, context) + class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView): template_name = "manage/threshold/irc/network/channels.html" parser_classes = [FormParser] @@ -219,7 +220,6 @@ class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView): :param channel: channel name """ channel = request.data["channel"] - print("DELETE CHANNEL", channel) parted = threshold.part_channel(net, channel) if parted["success"]: message = f"Requested part on relays: {', '.join(parted['relays'])}" @@ -264,6 +264,7 @@ class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView): } return render(request, self.template_name, context) + class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, APIView): """ List the channels a network is on.