Commit dc717ea3 by Őry Máté

dashboard: allow cloning permissions of parent template

parent a4d5963c
......@@ -90,9 +90,15 @@ class VmSaveForm(OperationForm):
def __init__(self, *args, **kwargs):
default = kwargs.pop('default', None)
clone = kwargs.pop('clone', False)
super(VmSaveForm, self).__init__(*args, **kwargs)
if default:
self.fields['name'].initial = default
if clone:
self.fields.insert(2, "clone", forms.BooleanField(
required=False, label=_("Clone template permissions"),
help_text=_("Clone the access list of parent template. Useful "
"for updating a template.")))
class VmCustomizeForm(forms.Form):
......
......@@ -457,6 +457,10 @@ class VmSaveView(FormOperationMixin, VmOperationView):
op = self.get_op()
val = super(VmSaveView, self).get_form_kwargs()
val['default'] = op._rename(op.instance.name)
obj = self.get_object()
if obj.template and obj.template.has_level(
self.request.user, "owner"):
val['clone'] = True
return val
......
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