Implement adding the next relay
This commit is contained in:
parent
7b97c96be3
commit
29fa14bc98
|
@ -90,7 +90,10 @@ def get_aliases():
|
|||
|
||||
|
||||
def add_relay(net, num):
|
||||
url = f"irc/network/{net}/{num}"
|
||||
if num:
|
||||
url = f"irc/network/{net}/{num}"
|
||||
else:
|
||||
url = f"irc/network/{net}"
|
||||
payload = {}
|
||||
created = threshold_request(url, payload, method="PUT")
|
||||
return created
|
||||
|
|
|
@ -58,16 +58,17 @@ def annotate_results(results_parsed):
|
|||
# Annotate the number channels the user is on
|
||||
num_chans = annotate_num_chans(net, nicks)
|
||||
for item in results_parsed:
|
||||
if item["net"] == net:
|
||||
if "nick" in item:
|
||||
if item["nick"] in online_info:
|
||||
item["online"] = online_info[item["nick"]]
|
||||
if "channel" in item:
|
||||
if item["channel"] in num_users:
|
||||
item["num_users"] = num_users[item["channel"]]
|
||||
if "nick" in item:
|
||||
if item["nick"] in num_chans:
|
||||
item["num_chans"] = num_chans[item["nick"]]
|
||||
if "net" in item:
|
||||
if item["net"] == net:
|
||||
if "nick" in item:
|
||||
if item["nick"] in online_info:
|
||||
item["online"] = online_info[item["nick"]]
|
||||
if "channel" in item:
|
||||
if item["channel"] in num_users:
|
||||
item["num_users"] = num_users[item["channel"]]
|
||||
if "nick" in item:
|
||||
if item["nick"] in num_chans:
|
||||
item["num_chans"] = num_chans[item["nick"]]
|
||||
|
||||
|
||||
def filter_blacklisted(user, response):
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
<div class="buttons">
|
||||
<button
|
||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||
hx-put="{% url 'threshold_irc_network_actions_add_relay' net %}"
|
||||
hx-trigger="click"
|
||||
hx-target="#channels"
|
||||
hx-target="#actions"
|
||||
hx-swap="outerHTML"
|
||||
class="button is-success">
|
||||
<span class="icon-text">
|
||||
|
|
|
@ -235,8 +235,7 @@ class ThresholdIRCNetworkActionsRelay(SuperUserRequiredMixin, APIView):
|
|||
Create a relay
|
||||
"""
|
||||
if "num" not in request.data:
|
||||
message = "No num specified"
|
||||
message_class = "danger"
|
||||
num = 0
|
||||
else:
|
||||
num = request.data["num"]
|
||||
if not num.isdigit():
|
||||
|
@ -244,15 +243,15 @@ class ThresholdIRCNetworkActionsRelay(SuperUserRequiredMixin, APIView):
|
|||
message_class = "danger"
|
||||
else:
|
||||
num = int(num)
|
||||
created = threshold.add_relay(net, num)
|
||||
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"
|
||||
created = threshold.add_relay(net, num)
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue