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
......@@ -175,8 +175,9 @@ class Operation(object):
raise ImproperlyConfigured(
"Set required_perms to () if none needed.")
if not user.has_perms(cls.required_perms):
raise PermissionDenied(
u"%s doesn't have the required permissions." % user)
raise humanize_exception(ugettext_noop(
"You don't have the required permissions."),
PermissionDenied())
if cls.superuser_required and not user.is_superuser:
raise humanize_exception(ugettext_noop(
"Superuser privileges are required."), PermissionDenied())
......
......@@ -13,7 +13,7 @@
<select class="form-control" name="proto" style="width: 70px;"><option>tcp</option><option>udp</option></select>
<div class="input-group-btn">
<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="visible-xs"><i class="fa fa-plus-circle"></i></span>
</button>
......
......@@ -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 %}
......
......@@ -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):
......@@ -647,6 +648,7 @@ class AddPortOperation(InstanceOperation):
name = _("open port")
description = _("Open the specified port.")
concurrency_check = False
acl_level = "operator"
required_perms = ('vm.config_ports', )
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