Implement provisioning relays

master
Mark Veidemanis 2 years ago
parent 779eb3697c
commit f9473ea615
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -40,6 +40,7 @@ from core.views.manage.threshold.irc import (
ThresholdIRCNetworkInfo,
ThresholdIRCNetworkInfoEdit,
ThresholdIRCNetworkRelayDel,
ThresholdIRCNetworkRelayProvision,
ThresholdIRCNetworkRelays,
ThresholdIRCNetworkRelayStatus,
ThresholdIRCNetworks,
@ -137,6 +138,11 @@ urlpatterns = [
ThresholdIRCActionsRegistration.as_view(),
name="threshold_irc_actions_registration_net",
),
path(
"manage/threshold/irc/network/<str:net>/<int:num>/provision/",
ThresholdIRCNetworkRelayProvision.as_view(),
name="threshold_irc_network_relay_provision",
),
path(
"manage/threshold/irc/actions/registration/",
ThresholdIRCActionsRegistration.as_view(),

@ -234,3 +234,10 @@ def irc_confirm_accounts(tokens):
payload = tokens
updated = threshold_request(url, payload, method="PUT")
return updated
def irc_provision_relay(net, num):
url = f"irc/network/{net}/{num}/provision"
payload = {}
provisioned = threshold_request(url, payload, method="POST")
return provisioned

@ -105,6 +105,18 @@
</span>
</button>
</div>
<div class="nowrap-child">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'threshold_irc_network_relay_provision' relay|index:'net' relay|index:'id' %}"
hx-target="#relays"
hx-swap="outerHTML"
class="button is-info">
<span class="icon" data-tooltip="Provision">
<i class="fa-solid fa-wrench" aria-hidden="true"></i>
</span>
</button>
</div>
</div>
</div>
</td>

@ -133,6 +133,31 @@ class ThresholdIRCNetworkRelayDel(SuperUserRequiredMixin, APIView):
return render(request, self.template_name, context)
class ThresholdIRCNetworkRelayProvision(SuperUserRequiredMixin, APIView):
template_name = "manage/threshold/irc/network/relays.html"
def post(self, request, net, num):
"""
Provision a relay
"""
provisioned = threshold.irc_provision_relay(net, num)
if provisioned["success"]:
message = f"Provisioned relay {num}"
message_class = "success"
else:
message = provisioned["reason"]
message_class = "danger"
relays = threshold.get_irc_relays(net)
context = {
"net": net,
"message": message,
"class": message_class,
"relays": relays["relays"],
}
return render(request, self.template_name, context)
class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView):
template_name = "manage/threshold/irc/network/relays.html"

@ -260,8 +260,6 @@ class DrilldownContextModal(APIView):
query_params["mtype"] = None
if request.user.is_superuser:
if query_params["type"] in ["query", "notice"]:
print("BOT NICK", query_params["channel"])
print("QUERY NICK", query_params["nick"])
nicks = [query_params["channel"], query_params["nick"]]
query_params["sorting"] = "desc"
if (

Loading…
Cancel
Save