Fix authed variable and switch join/part API to use JSON

This commit is contained in:
Mark Veidemanis 2022-08-14 09:24:21 +01:00
parent 81708ef490
commit 69b4cb8865
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 7 additions and 7 deletions

View File

@ -36,6 +36,7 @@ from core.views.manage.threshold.irc import (
ThresholdIRCNetworkActionsAuto, ThresholdIRCNetworkActionsAuto,
ThresholdIRCNetworkActionsRelay, ThresholdIRCNetworkActionsRelay,
ThresholdIRCNetworkChannels, ThresholdIRCNetworkChannels,
ThresholdIRCNetworkChannelsAPI,
ThresholdIRCNetworkDel, ThresholdIRCNetworkDel,
ThresholdIRCNetworkInfo, ThresholdIRCNetworkInfo,
ThresholdIRCNetworkInfoEdit, ThresholdIRCNetworkInfoEdit,
@ -48,7 +49,6 @@ from core.views.manage.threshold.irc import (
ThresholdIRCOverviewAlerts, ThresholdIRCOverviewAlerts,
ThresholdIRCSendMessage, ThresholdIRCSendMessage,
ThresholdIRCStats, ThresholdIRCStats,
ThresholdIRCNetworkChannelsAPI,
) )
# Management stuff # Management stuff

View File

@ -75,9 +75,8 @@ def part_channel(net, channel):
def join_channel(net, channel): def join_channel(net, channel):
channel = urllib.parse.quote(channel, safe="") url = f"irc/network/{net}/channel"
url = f"irc/network/{net}/channel/{channel}" payload = {"channel": channel}
payload = {}
joined = threshold_request(url, payload, method="PUT") joined = threshold_request(url, payload, method="PUT")
if not joined: if not joined:
return {} return {}

View File

@ -44,7 +44,7 @@
{% endif %} {% endif %}
</td> </td>
<td> <td>
{% if relay.authenticated %} {% if relay.authed %}
<span class="icon has-text-success"> <span class="icon has-text-success">
<i class="fa-solid fa-check" aria-hidden="true"></i> <i class="fa-solid fa-check" aria-hidden="true"></i>
</span> </span>

View File

@ -1,6 +1,6 @@
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, JSONParser from rest_framework.parsers import FormParser
from rest_framework.views import APIView from rest_framework.views import APIView
from core.lib.manage import threshold from core.lib.manage import threshold
@ -208,6 +208,7 @@ class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView):
} }
return render(request, self.template_name, context) return render(request, self.template_name, context)
class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView): class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView):
template_name = "manage/threshold/irc/network/channels.html" template_name = "manage/threshold/irc/network/channels.html"
parser_classes = [FormParser] parser_classes = [FormParser]
@ -219,7 +220,6 @@ class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView):
:param channel: channel name :param channel: channel name
""" """
channel = request.data["channel"] channel = request.data["channel"]
print("DELETE CHANNEL", channel)
parted = threshold.part_channel(net, channel) parted = threshold.part_channel(net, channel)
if parted["success"]: if parted["success"]:
message = f"Requested part on relays: {', '.join(parted['relays'])}" message = f"Requested part on relays: {', '.join(parted['relays'])}"
@ -264,6 +264,7 @@ class ThresholdIRCNetworkChannelsAPI(SuperUserRequiredMixin, APIView):
} }
return render(request, self.template_name, context) return render(request, self.template_name, context)
class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, APIView): class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, APIView):
""" """
List the channels a network is on. List the channels a network is on.