Implement running list on a network
This commit is contained in:
parent
766b530ace
commit
fa53e11ff0
|
@ -28,6 +28,7 @@ from core.views.manage.threshold.irc import (
|
|||
ThresholdIRCAliasesEdit,
|
||||
ThresholdIRCNetworkActions,
|
||||
ThresholdIRCNetworkActionsAuto,
|
||||
ThresholdIRCNetworkActionsList,
|
||||
ThresholdIRCNetworkActionsRelay,
|
||||
ThresholdIRCNetworkChannels,
|
||||
ThresholdIRCNetworkInfo,
|
||||
|
@ -177,6 +178,11 @@ urlpatterns = [
|
|||
ThresholdIRCNetworkActionsAuto.as_view(),
|
||||
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/users/", ThresholdUsers.as_view(), name="users"),
|
||||
|
|
|
@ -118,3 +118,10 @@ def run_auto(net):
|
|||
payload = {}
|
||||
deleted = threshold_request(url, payload, method="POST")
|
||||
return deleted
|
||||
|
||||
|
||||
def run_list(net):
|
||||
url = f"irc/list/{net}"
|
||||
payload = {}
|
||||
ran = threshold_request(url, payload, method="POST")
|
||||
return ran
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
</button>
|
||||
<button
|
||||
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">
|
||||
<span class="icon-text">
|
||||
<span class="icon">
|
||||
|
|
|
@ -298,6 +298,34 @@ class ThresholdIRCNetworkActionsAuto(SuperUserRequiredMixin, View):
|
|||
if ran["success"]:
|
||||
message = f"Ran auto on network {net}"
|
||||
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:
|
||||
message = ran["reason"]
|
||||
message_class = "danger"
|
||||
|
|
Loading…
Reference in New Issue