Implement provisioning relays
This commit is contained in:
parent
779eb3697c
commit
f9473ea615
|
@ -40,6 +40,7 @@ from core.views.manage.threshold.irc import (
|
||||||
ThresholdIRCNetworkInfo,
|
ThresholdIRCNetworkInfo,
|
||||||
ThresholdIRCNetworkInfoEdit,
|
ThresholdIRCNetworkInfoEdit,
|
||||||
ThresholdIRCNetworkRelayDel,
|
ThresholdIRCNetworkRelayDel,
|
||||||
|
ThresholdIRCNetworkRelayProvision,
|
||||||
ThresholdIRCNetworkRelays,
|
ThresholdIRCNetworkRelays,
|
||||||
ThresholdIRCNetworkRelayStatus,
|
ThresholdIRCNetworkRelayStatus,
|
||||||
ThresholdIRCNetworks,
|
ThresholdIRCNetworks,
|
||||||
|
@ -137,6 +138,11 @@ urlpatterns = [
|
||||||
ThresholdIRCActionsRegistration.as_view(),
|
ThresholdIRCActionsRegistration.as_view(),
|
||||||
name="threshold_irc_actions_registration_net",
|
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(
|
path(
|
||||||
"manage/threshold/irc/actions/registration/",
|
"manage/threshold/irc/actions/registration/",
|
||||||
ThresholdIRCActionsRegistration.as_view(),
|
ThresholdIRCActionsRegistration.as_view(),
|
||||||
|
|
|
@ -234,3 +234,10 @@ def irc_confirm_accounts(tokens):
|
||||||
payload = tokens
|
payload = tokens
|
||||||
updated = threshold_request(url, payload, method="PUT")
|
updated = threshold_request(url, payload, method="PUT")
|
||||||
return updated
|
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>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -133,6 +133,31 @@ class ThresholdIRCNetworkRelayDel(SuperUserRequiredMixin, APIView):
|
||||||
return render(request, self.template_name, context)
|
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):
|
class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView):
|
||||||
template_name = "manage/threshold/irc/network/relays.html"
|
template_name = "manage/threshold/irc/network/relays.html"
|
||||||
|
|
||||||
|
|
|
@ -260,8 +260,6 @@ class DrilldownContextModal(APIView):
|
||||||
query_params["mtype"] = None
|
query_params["mtype"] = None
|
||||||
if request.user.is_superuser:
|
if request.user.is_superuser:
|
||||||
if query_params["type"] in ["query", "notice"]:
|
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"]]
|
nicks = [query_params["channel"], query_params["nick"]]
|
||||||
query_params["sorting"] = "desc"
|
query_params["sorting"] = "desc"
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue