Commit c958a20e by Kálmán Viktor

request: disable requests for deleted vms

parent cb2d9cff
Pipeline #58 passed with stage
in 0 seconds
......@@ -8,7 +8,7 @@
<a class="btn btn-default" href="{{object.get_absolute_url}}" data-dismiss="modal">
{% trans "Cancel" %}
</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"
href="{% url "request.views.request-lease" vm_pk=object.pk %}">
<i class="fa fa-forward"></i>
......
......@@ -59,8 +59,8 @@
{% if instance.is_expiring %}<i class="fa fa-warning-sign text-danger"></i>{% endif %}
<span id="vm-details-renew-op">
{% with op=op.renew %}{% if op %}
<a href="{{op.get_url}}" class="btn btn-{{op.effect}} btn-xs
operation operation-{{op.op}}">
<a href="{{op.get_url}}" class="btn btn-xs operation operation-{{ op.op }}
{% if op.disabled %}btn-default disabled{% else %}btn-{{op.effect}}{% endif %}">
<i class="fa fa-{{op.icon}}"></i>
{{op.name}}
</a>
......
......@@ -208,6 +208,12 @@ class VmRequestMixin(LoginRequiredMixin, object):
user = self.request.user
if not vm.has_level(user, self.user_level):
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)
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