From 2be155b578c1f90dc9fa3f6330c808d1159143df Mon Sep 17 00:00:00 2001
From: Kálmán Viktor <kviktor@cloud.bme.hu>
Date: Wed, 2 Mar 2016 12:45:54 +0100
Subject: [PATCH] dashboard: enable port closing for operators

and disable the remove button for non ops
---
 circle/dashboard/templates/dashboard/vm-detail/network.html | 7 +++++--
 circle/vm/operations.py                                     | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/circle/dashboard/templates/dashboard/vm-detail/network.html b/circle/dashboard/templates/dashboard/vm-detail/network.html
index c8df8d5..13c3391 100644
--- a/circle/dashboard/templates/dashboard/vm-detail/network.html
+++ b/circle/dashboard/templates/dashboard/vm-detail/network.html
@@ -83,7 +83,8 @@
                         <span class="operation-wrapper">
                           <a href="{{ op.remove_port.get_url }}?rule={{ l.ipv4.pk }}"
                              class="btn btn-link btn-xs operation"
-                             title="{% trans "Remove" %}">
+                             title="{% trans "Remove" %}"
+                             {% if not op.remove_port %}disabled{% endif %}>
                             <i class="fa fa-times"><span class="sr-only">{% trans "Remove" %}</span></i>
                           </a>
                         </span>
@@ -118,7 +119,9 @@
                         {{ l.private }}/{{ l.proto }}
                       </td>
                       <td>
-                        <a href="{{ op.remove_port.get_url }}?rule={{ l.ipv4.pk }}" class="btn btn-link btn-xs vm-details-remove-port" data-rule="{{ l.ipv6.pk }}" title="{% trans "Remove" %}"><i class="fa fa-times"><span class="sr-only">{% trans "Remove" %}</span></i></a>
+                        <a href="{{ op.remove_port.get_url }}?rule={{ l.ipv4.pk }}" class="btn btn-link btn-xs vm-details-remove-port" data-rule="{{ l.ipv6.pk }}" title="{% trans "Remove" %}" {% if not op.remove_port %}disabled{% endif %}>
+                          <i class="fa fa-times"><span class="sr-only">{% trans "Remove" %}</span></i>
+                        </a>
                       </td>
                     </tr>
                   {% endif %}
diff --git a/circle/vm/operations.py b/circle/vm/operations.py
index 16cee81..061eec4 100644
--- a/circle/vm/operations.py
+++ b/circle/vm/operations.py
@@ -629,6 +629,7 @@ class RemovePortOperation(InstanceOperation):
     name = _("close port")
     description = _("Close the specified port.")
     concurrency_check = False
+    acl_level = "operator"
     required_perms = ('vm.config_ports', )
 
     def _operation(self, activity, rule):
--
libgit2 0.26.0