Implement adding relays by number
This commit is contained in:
@@ -132,7 +132,7 @@ class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, APIView):
|
||||
:param channel: channel name
|
||||
"""
|
||||
parted = threshold.part_channel(net, channel)
|
||||
if parted:
|
||||
if parted["success"]:
|
||||
message = f"Requested part on relays: {', '.join(parted['relays'])}"
|
||||
message_class = "success"
|
||||
else:
|
||||
@@ -158,10 +158,9 @@ class ThresholdIRCNetworkChannels(SuperUserRequiredMixin, APIView):
|
||||
message_class = "danger"
|
||||
else:
|
||||
channel = request.data["channel"]
|
||||
print("CHANNEL", channel)
|
||||
joined = threshold.join_channel(net, channel)
|
||||
print("JOINED", joined)
|
||||
if joined:
|
||||
if joined["success"]:
|
||||
message = f"Requested join on relay: {joined['relays']}"
|
||||
message_class = "success"
|
||||
else:
|
||||
@@ -191,6 +190,7 @@ class ThresholdIRCAliases(SuperUserRequiredMixin, APIView):
|
||||
}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
||||
class ThresholdIRCNetworkActions(SuperUserRequiredMixin, View):
|
||||
template_name = "manage/threshold/irc/network/actions.html"
|
||||
|
||||
@@ -198,5 +198,43 @@ class ThresholdIRCNetworkActions(SuperUserRequiredMixin, View):
|
||||
"""
|
||||
Get actions page.
|
||||
"""
|
||||
context = {"net": net}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
return render(request, self.template_name)
|
||||
|
||||
class ThresholdIRCNetworkActionsAddRelay(SuperUserRequiredMixin, APIView):
|
||||
template_name = "manage/threshold/irc/network/actions.html"
|
||||
parser_classes = [FormParser]
|
||||
|
||||
def put(self, request, net):
|
||||
"""
|
||||
Create a relay
|
||||
"""
|
||||
print("ACTION PUT", request.data, net)
|
||||
if "num" not in request.data:
|
||||
message = "No num specified"
|
||||
message_class = "danger"
|
||||
else:
|
||||
num = request.data["num"]
|
||||
if not num.isdigit():
|
||||
message = "Num is not an integer"
|
||||
message_class = "danger"
|
||||
else:
|
||||
num = int(num)
|
||||
created = threshold.add_relay(net, num)
|
||||
print("CREATED", created)
|
||||
if created["success"]:
|
||||
id = created["id"]
|
||||
alias = created["alias"]
|
||||
message = f"Created new relay {id} with alias {alias}"
|
||||
message_class = "success"
|
||||
else:
|
||||
message = created["reason"]
|
||||
message_class = "danger"
|
||||
|
||||
context = {
|
||||
"net": net,
|
||||
"message": message,
|
||||
"class": message_class,
|
||||
}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
Reference in New Issue
Block a user