Commit 0edc8ff2 by Kálmán Viktor

dashboard: pass the user to create empty/url disk

parent 70b50134
......@@ -734,6 +734,7 @@ class DiskAddForm(forms.Form):
def __init__(self, *args, **kwargs):
self.is_template = kwargs.pop("is_template")
self.object_pk = kwargs.pop("object_pk")
self.user = kwargs.pop("user")
super(DiskAddForm, self).__init__(*args, **kwargs)
self.initial['is_template'] = 1 if self.is_template is True else 0
self.initial['object_pk'] = self.object_pk
......@@ -771,7 +772,7 @@ class DiskAddForm(forms.Form):
'size': data['size'],
'dev_num': "a",
}
d = Disk.create_empty(instance=inst, user=None, **kwargs)
d = Disk.create_empty(instance=inst, user=self.user, **kwargs)
else:
kwargs = {
'name': data['name'],
......@@ -779,7 +780,7 @@ class DiskAddForm(forms.Form):
'dev_num': "a",
}
Disk.create_from_url_async(data['url'], instance=inst,
user=None, **kwargs)
user=self.user, **kwargs)
d = None
return d
......
......@@ -195,6 +195,7 @@ class VmDetailView(CheckedDetailView):
context['acl'] = get_vm_acl_data(instance)
context['forms'] = {
'disk_add_form': DiskAddForm(
user=self.request.user,
is_template=False, object_pk=self.get_object().pk,
prefix="disk"),
}
......@@ -749,6 +750,7 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
context['acl'] = get_vm_acl_data(obj)
context['disks'] = obj.disks.all()
context['disk_add_form'] = DiskAddForm(
user=self.request.user,
is_template=True,
object_pk=obj.pk,
prefix="disk",
......@@ -1756,6 +1758,7 @@ class DiskAddView(TemplateView):
form = DiskAddForm(
self.request.POST,
user=self.request.user,
is_template=is_template, object_pk=object_pk,
prefix="disk"
)
......
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