Implement running list on a network

This commit is contained in:
Mark Veidemanis 2022-08-01 21:39:11 +01:00
parent 766b530ace
commit fa53e11ff0
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 45 additions and 0 deletions

View File

@ -28,6 +28,7 @@ from core.views.manage.threshold.irc import (
ThresholdIRCAliasesEdit, ThresholdIRCAliasesEdit,
ThresholdIRCNetworkActions, ThresholdIRCNetworkActions,
ThresholdIRCNetworkActionsAuto, ThresholdIRCNetworkActionsAuto,
ThresholdIRCNetworkActionsList,
ThresholdIRCNetworkActionsRelay, ThresholdIRCNetworkActionsRelay,
ThresholdIRCNetworkChannels, ThresholdIRCNetworkChannels,
ThresholdIRCNetworkInfo, ThresholdIRCNetworkInfo,
@ -177,6 +178,11 @@ urlpatterns = [
ThresholdIRCNetworkActionsAuto.as_view(), ThresholdIRCNetworkActionsAuto.as_view(),
name="threshold_irc_network_actions_auto", name="threshold_irc_network_actions_auto",
), ),
path(
"manage/threshold/irc/list/<str:net>/",
ThresholdIRCNetworkActionsList.as_view(),
name="threshold_irc_network_actions_list",
),
## ##
path("api/chans/", ThresholdChans.as_view(), name="chans"), path("api/chans/", ThresholdChans.as_view(), name="chans"),
path("api/users/", ThresholdUsers.as_view(), name="users"), path("api/users/", ThresholdUsers.as_view(), name="users"),

View File

@ -118,3 +118,10 @@ def run_auto(net):
payload = {} payload = {}
deleted = threshold_request(url, payload, method="POST") deleted = threshold_request(url, payload, method="POST")
return deleted return deleted
def run_list(net):
url = f"irc/list/{net}"
payload = {}
ran = threshold_request(url, payload, method="POST")
return ran

View File

@ -35,6 +35,10 @@
</button> </button>
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'threshold_irc_network_actions_list' net %}"
hx-trigger="click"
hx-target="#actions"
hx-swap="outerHTML"
class="button is-success"> class="button is-success">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">

View File

@ -298,6 +298,34 @@ class ThresholdIRCNetworkActionsAuto(SuperUserRequiredMixin, View):
if ran["success"]: if ran["success"]:
message = f"Ran auto on network {net}" message = f"Ran auto on network {net}"
message_class = "success" message_class = "success"
if "message" in ran:
message = ran["message"]
else:
message = ran["reason"]
message_class = "danger"
context = {
"net": net,
"message": message,
"class": message_class,
}
return render(request, self.template_name, context)
class ThresholdIRCNetworkActionsList(SuperUserRequiredMixin, View):
template_name = "manage/threshold/irc/network/actions.html"
def post(self, request, net):
"""
Run LIST on network.
"""
ran = threshold.run_list(net)
if ran["success"]:
message = f"Ran list on network {net}"
message_class = "success"
if "message" in ran:
message = ran["message"]
else: else:
message = ran["reason"] message = ran["reason"]
message_class = "danger" message_class = "danger"