Commit 68dc757d by Dudás Ádám

Merge branch 'issue-447' into 'master'

Disable requests for deleted vms

Closes #447

See merge request !368
parents f3ef3c2a c958a20e
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<a class="btn btn-default" href="{{object.get_absolute_url}}" data-dismiss="modal"> <a class="btn btn-default" href="{{object.get_absolute_url}}" data-dismiss="modal">
{% trans "Cancel" %} {% trans "Cancel" %}
</a> </a>
{% if lease_types and not request.token_user %} {% if object.active and lease_types and not request.token_user %}
<a class="btn btn-primary" id="vm-renew-request-lease-button" <a class="btn btn-primary" id="vm-renew-request-lease-button"
href="{% url "request.views.request-lease" vm_pk=object.pk %}"> href="{% url "request.views.request-lease" vm_pk=object.pk %}">
<i class="fa fa-forward"></i> <i class="fa fa-forward"></i>
......
...@@ -59,8 +59,8 @@ ...@@ -59,8 +59,8 @@
{% if instance.is_expiring %}<i class="fa fa-warning-sign text-danger"></i>{% endif %} {% if instance.is_expiring %}<i class="fa fa-warning-sign text-danger"></i>{% endif %}
<span id="vm-details-renew-op"> <span id="vm-details-renew-op">
{% with op=op.renew %}{% if op %} {% with op=op.renew %}{% if op %}
<a href="{{op.get_url}}" class="btn btn-{{op.effect}} btn-xs <a href="{{op.get_url}}" class="btn btn-xs operation operation-{{ op.op }}
operation operation-{{op.op}}"> {% if op.disabled %}btn-default disabled{% else %}btn-{{op.effect}}{% endif %}">
<i class="fa fa-{{op.icon}}"></i> <i class="fa fa-{{op.icon}}"></i>
{{op.name}} {{op.name}}
</a> </a>
......
...@@ -208,6 +208,12 @@ class VmRequestMixin(LoginRequiredMixin, object): ...@@ -208,6 +208,12 @@ class VmRequestMixin(LoginRequiredMixin, object):
user = self.request.user user = self.request.user
if not vm.has_level(user, self.user_level): if not vm.has_level(user, self.user_level):
raise PermissionDenied() raise PermissionDenied()
if vm.destroyed_at:
message = _("Instance %(instance)s has already been destroyed.")
messages.error(self.request, message % {'instance': vm.name})
return redirect(vm.get_absolute_url())
return super(VmRequestMixin, self).dispatch(*args, **kwargs) return super(VmRequestMixin, self).dispatch(*args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
......
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