Commit 13d89bae by Kálmán Viktor

Merge branch 'issue-437' into 'master'

Fix add port permissions

closes #437

See merge request !359
parents 50ac15ee b2bb54c4
Pipeline #10 passed with stage
in 0 seconds
...@@ -175,8 +175,9 @@ class Operation(object): ...@@ -175,8 +175,9 @@ class Operation(object):
raise ImproperlyConfigured( raise ImproperlyConfigured(
"Set required_perms to () if none needed.") "Set required_perms to () if none needed.")
if not user.has_perms(cls.required_perms): if not user.has_perms(cls.required_perms):
raise PermissionDenied( raise humanize_exception(ugettext_noop(
u"%s doesn't have the required permissions." % user) "You don't have the required permissions."),
PermissionDenied())
if cls.superuser_required and not user.is_superuser: if cls.superuser_required and not user.is_superuser:
raise humanize_exception(ugettext_noop( raise humanize_exception(ugettext_noop(
"Superuser privileges are required."), PermissionDenied()) "Superuser privileges are required."), PermissionDenied())
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<select class="form-control" name="proto" style="width: 70px;"><option>tcp</option><option>udp</option></select> <select class="form-control" name="proto" style="width: 70px;"><option>tcp</option><option>udp</option></select>
<div class="input-group-btn"> <div class="input-group-btn">
<button type="submit" class="btn btn-success btn-sm <button type="submit" class="btn btn-success btn-sm
{% if not is_operator %}disabled{% endif %}"> {% if not op.add_port %}disabled{% endif %}">
<span class="hidden-xs">{% trans "Add" %}</span> <span class="hidden-xs">{% trans "Add" %}</span>
<span class="visible-xs"><i class="fa fa-plus-circle"></i></span> <span class="visible-xs"><i class="fa fa-plus-circle"></i></span>
</button> </button>
......
...@@ -83,7 +83,8 @@ ...@@ -83,7 +83,8 @@
<span class="operation-wrapper"> <span class="operation-wrapper">
<a href="{{ op.remove_port.get_url }}?rule={{ l.ipv4.pk }}" <a href="{{ op.remove_port.get_url }}?rule={{ l.ipv4.pk }}"
class="btn btn-link btn-xs operation" 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> <i class="fa fa-times"><span class="sr-only">{% trans "Remove" %}</span></i>
</a> </a>
</span> </span>
...@@ -118,7 +119,9 @@ ...@@ -118,7 +119,9 @@
{{ l.private }}/{{ l.proto }} {{ l.private }}/{{ l.proto }}
</td> </td>
<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> </td>
</tr> </tr>
{% endif %} {% endif %}
......
...@@ -629,6 +629,7 @@ class RemovePortOperation(InstanceOperation): ...@@ -629,6 +629,7 @@ class RemovePortOperation(InstanceOperation):
name = _("close port") name = _("close port")
description = _("Close the specified port.") description = _("Close the specified port.")
concurrency_check = False concurrency_check = False
acl_level = "operator"
required_perms = ('vm.config_ports', ) required_perms = ('vm.config_ports', )
def _operation(self, activity, rule): def _operation(self, activity, rule):
...@@ -647,6 +648,7 @@ class AddPortOperation(InstanceOperation): ...@@ -647,6 +648,7 @@ class AddPortOperation(InstanceOperation):
name = _("open port") name = _("open port")
description = _("Open the specified port.") description = _("Open the specified port.")
concurrency_check = False concurrency_check = False
acl_level = "operator"
required_perms = ('vm.config_ports', ) required_perms = ('vm.config_ports', )
def _operation(self, activity, host, proto, port): def _operation(self, activity, host, proto, port):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment