diff --git a/app/urls.py b/app/urls.py index b03cb93..df142ab 100644 --- a/app/urls.py +++ b/app/urls.py @@ -33,6 +33,7 @@ from core.views.manage.threshold.irc import ( ThresholdIRCNetworkActionsList, ThresholdIRCNetworkActionsRelay, ThresholdIRCNetworkChannels, + ThresholdIRCNetworkDel, ThresholdIRCNetworkInfo, ThresholdIRCNetworkInfoEdit, ThresholdIRCNetworkRelayDel, @@ -119,6 +120,11 @@ urlpatterns = [ ThresholdIRCNetwork.as_view(), name="threshold_irc_network", ), + path( + "manage/threshold/irc/overview/network//delete/", + ThresholdIRCNetworkDel.as_view(), + name="threshold_irc_network_del", + ), path( "manage/threshold/irc/network//info/", ThresholdIRCNetworkInfo.as_view(), diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 826dc6c..e289c61 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -132,3 +132,10 @@ def create_network(data): payload = data ran = threshold_request(url, payload, method="PUT") return ran + + +def del_network(net): + url = f"irc/network/{net}" + payload = {} + deleted = threshold_request(url, payload, method="DELETE") + return deleted diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index 067d85c..5e7374d 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -55,40 +55,40 @@
- {% if relay.enabled %} + {% if relay.enabled %} + + {% else %} + + {% endif %} - {% else %} - - {% endif %} - -
+ {% endfor %} diff --git a/core/templates/manage/threshold/irc/overview/modals/add-network.html b/core/templates/manage/threshold/irc/overview/modals/add-network.html index 4d7d9ff..c2e9167 100644 --- a/core/templates/manage/threshold/irc/overview/modals/add-network.html +++ b/core/templates/manage/threshold/irc/overview/modals/add-network.html @@ -12,7 +12,6 @@ hx-put="{% url 'threshold_irc_actions_add-network' %}" hx-target="#networks" hx-swap="outerHTML"> -
@@ -60,7 +59,7 @@
- + + {% endfor %} diff --git a/core/templates/manage/threshold/partials/notify.html b/core/templates/manage/threshold/partials/notify.html index 6cdaccb..80a3852 100644 --- a/core/templates/manage/threshold/partials/notify.html +++ b/core/templates/manage/threshold/partials/notify.html @@ -1,5 +1,5 @@ {% if message is not None %} -
- {{ message }} -
+
+ {{ message }} +
{% endif %} \ No newline at end of file diff --git a/core/views/manage/threshold/irc.py b/core/views/manage/threshold/irc.py index a5dfaa1..d2a507c 100644 --- a/core/views/manage/threshold/irc.py +++ b/core/views/manage/threshold/irc.py @@ -25,6 +25,25 @@ class ThresholdIRCNetworks(SuperUserRequiredMixin, View): return render(request, self.template_name, context) +class ThresholdIRCNetworkDel(SuperUserRequiredMixin, View): + template_name = "manage/threshold/irc/overview/networks.html" + + def delete(self, request, net): + deleted = threshold.del_network(net) + message = f"Deleted network {net}" + message_class = "success" + if not deleted["success"]: + message = deleted["reason"] + message_class = "danger" + networks = threshold.get_irc_networks() + context = { + "networks": networks, + "message": message, + "class": message_class, + } + return render(request, self.template_name, context) + + class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View): template_name = "manage/threshold/irc/network/info.html"