Commit 5fcb2d72 by Őry Máté

dashboard: set initial name for save_as

parent faaace05
...@@ -79,6 +79,12 @@ class VmSaveForm(forms.Form): ...@@ -79,6 +79,12 @@ class VmSaveForm(forms.Form):
helper.form_tag = False helper.form_tag = False
return helper return helper
def __init__(self, *args, **kwargs):
default = kwargs.pop('default', None)
super(VmSaveForm, self).__init__(*args, **kwargs)
if default:
self.fields['name'].initial = default
class VmCustomizeForm(forms.Form): class VmCustomizeForm(forms.Form):
name = forms.CharField(widget=forms.TextInput(attrs={ name = forms.CharField(widget=forms.TextInput(attrs={
......
...@@ -453,6 +453,12 @@ class VmSaveView(FormOperationMixin, VmOperationView): ...@@ -453,6 +453,12 @@ class VmSaveView(FormOperationMixin, VmOperationView):
effect = 'info' effect = 'info'
form_class = VmSaveForm form_class = VmSaveForm
def get_form_kwargs(self):
op = self.get_op()
val = super(VmSaveView, self).get_form_kwargs()
val['default'] = op._rename(op.instance.name)
return val
class VmResourcesChangeView(VmOperationView): class VmResourcesChangeView(VmOperationView):
op = 'resources_change' op = 'resources_change'
......
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