Commit bf0575e5 by Bach Dániel

dashboard: remove copypasted code

parent 00df56d1
...@@ -369,37 +369,8 @@ class VmAddInterfaceView(FormOperationMixin, VmOperationView): ...@@ -369,37 +369,8 @@ class VmAddInterfaceView(FormOperationMixin, VmOperationView):
return val return val
class VmDiskResizeView(FormOperationMixin, VmOperationView): class VmDiskModifyView(FormOperationMixin, VmOperationView):
op = 'resize_disk'
form_class = VmDiskResizeForm
show_in_toolbar = False
icon = 'arrows-alt'
effect = "warning"
def get_form_kwargs(self):
choices = self.get_op().instance.disks
disk_pk = self.request.GET.get('disk')
if disk_pk:
try:
default = choices.get(pk=disk_pk)
except (ValueError, Disk.DoesNotExist):
raise Http404()
else:
default = None
val = super(VmDiskResizeView, self).get_form_kwargs()
val.update({'choices': choices, 'default': default})
return val
class VmDiskRemoveView(FormOperationMixin, VmOperationView):
op = 'remove_disk'
form_class = VmDiskRemoveForm
show_in_toolbar = False show_in_toolbar = False
icon = "times"
effect = "danger"
def get_form_kwargs(self): def get_form_kwargs(self):
choices = self.get_op().instance.disks choices = self.get_op().instance.disks
...@@ -412,7 +383,7 @@ class VmDiskRemoveView(FormOperationMixin, VmOperationView): ...@@ -412,7 +383,7 @@ class VmDiskRemoveView(FormOperationMixin, VmOperationView):
else: else:
default = None default = None
val = super(VmDiskRemoveView, self).get_form_kwargs() val = super(VmDiskModifyView, self).get_form_kwargs()
val.update({'choices': choices, 'default': default}) val.update({'choices': choices, 'default': default})
return val return val
...@@ -663,8 +634,12 @@ vm_ops = OrderedDict([ ...@@ -663,8 +634,12 @@ vm_ops = OrderedDict([
op='destroy', icon='times', effect='danger')), op='destroy', icon='times', effect='danger')),
('create_disk', VmCreateDiskView), ('create_disk', VmCreateDiskView),
('download_disk', VmDownloadDiskView), ('download_disk', VmDownloadDiskView),
('resize_disk', VmDiskResizeView), ('resize_disk', VmDiskModifyView.factory(
('remove_disk', VmDiskRemoveView), op='resize_disk', form_class=VmDiskResizeForm,
icon='arrows-alt', effect="warning")),
('remove_disk', VmDiskModifyView.factory(
op='remove_disk', form_class=VmDiskRemoveForm,
icon='times', effect="danger")),
('add_interface', VmAddInterfaceView), ('add_interface', VmAddInterfaceView),
('renew', VmRenewView), ('renew', VmRenewView),
('resources_change', VmResourcesChangeView), ('resources_change', VmResourcesChangeView),
......
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