Commit 8dc295a5 by Kálmán Viktor

dashboard: resize request only for resizable disks

parent 747fd41c
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
{% if op.resize_disk.disabled %}disabled{% endif %}"> {% if op.resize_disk.disabled %}disabled{% endif %}">
<i class="fa fa-{{ op.resize_disk.icon }} fa-fw-12"></i> {% trans "Resize" %} <i class="fa fa-{{ op.resize_disk.icon }} fa-fw-12"></i> {% trans "Resize" %}
</a> </a>
{% else %} {% elif d.is_resizable %}
<a href="{% url "request.views.request-resize" vm_pk=instance.pk disk_pk=d.pk %}" class="btn btn-xs btn-primary operation"> <a href="{% url "request.views.request-resize" vm_pk=instance.pk disk_pk=d.pk %}" class="btn btn-xs btn-primary operation">
<i class="fa fa-arrows-alt fa-fw-12"></i> {% trans "Request resize" %} <i class="fa fa-arrows-alt fa-fw-12"></i> {% trans "Request resize" %}
</a> </a>
{% else %}
<small class="text-muted">{% trans "Cannot be resized" %}</small>
{% endif %} {% endif %}
{% if op.remove_disk %} {% if op.remove_disk %}
<a href="{{ op.remove_disk.get_url }}?disk={{d.pk}}" <a href="{{ op.remove_disk.get_url }}?disk={{d.pk}}"
......
{% spaceless %} {% spaceless %}
{% if LANGUAGE_CODE == "en" %} {% if LANGUAGE_CODE == "en" %}
Why do you need bigger disk? Why do you need a bigger disk?
{% else %} {# place your translations here #} {% else %} {# place your translations here #}
Why do you need bigger disk? Why do you need a bigger disk?
{% endif %} {% endif %}
{% endspaceless %} {% endspaceless %}
...@@ -327,8 +327,11 @@ class ResizeRequestView(VmRequestMixin, FormView): ...@@ -327,8 +327,11 @@ class ResizeRequestView(VmRequestMixin, FormView):
return context return context
def form_valid(self, form): def form_valid(self, form):
vm = self.get_vm()
disk = self.get_disk() disk = self.get_disk()
if not disk.is_resizable:
raise SuspiciousOperation
vm = self.get_vm()
data = form.cleaned_data data = form.cleaned_data
user = self.request.user user = self.request.user
......
...@@ -539,3 +539,7 @@ class Disk(TimeStampedModel): ...@@ -539,3 +539,7 @@ class Disk(TimeStampedModel):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('dashboard.views.disk-detail', kwargs={'pk': self.pk}) return reverse('dashboard.views.disk-detail', kwargs={'pk': self.pk})
@property
def is_resizable(self):
return self.type in ('qcow2-norm', 'raw-rw')
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