Commit ce14cf3e by Őry Máté

dashboard: use FormOperationMixin for VmSaveView

parent a4126adf
......@@ -47,6 +47,11 @@ from vm.models import (
from .models import Profile, GroupProfile
class VmSaveForm(forms.Form):
name = forms.CharField(max_length=100, label=_('Name'),
help_text=_('Human readable name of template.'))
class VmCustomizeForm(forms.Form):
name = forms.CharField()
cpu_priority = forms.IntegerField()
......
......@@ -60,7 +60,7 @@ from .forms import (
CircleAuthenticationForm, DiskAddForm, HostForm, LeaseForm, MyProfileForm,
NodeForm, TemplateForm, TraitForm, VmCustomizeForm, GroupCreateForm,
UserCreationForm, GroupProfileUpdateForm,
CirclePasswordChangeForm
CirclePasswordChangeForm, VmSaveForm,
)
from .tables import (
......@@ -624,25 +624,11 @@ class VmMigrateView(VmOperationView):
return super(VmMigrateView, self).post(request, extra, *args, **kwargs)
class VmSaveView(VmOperationView):
class VmSaveView(FormOperationMixin, VmOperationView):
op = 'save_as_template'
icon = 'save'
template_name = 'dashboard/_vm-save.html'
def get_context_data(self, **kwargs):
ctx = super(VmSaveView, self).get_context_data(**kwargs)
ctx['name'] = self.get_op()._rename(self.object.name)
return ctx
def post(self, request, extra=None, *args, **kwargs):
if extra is None:
extra = {}
name = self.request.POST.get("name")
if name:
extra["name"] = name
return super(VmSaveView, self).post(request, extra, *args, **kwargs)
form_class = VmSaveForm
vm_ops = {
'reset': VmOperationView.factory(op='reset', icon='bolt'),
......
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