Commit c1f12679 by Guba Sándor

Merge branch 'feature-save-lease' into 'master'

Feature Save Lease
parents 7212fdbc 8c20ce75
...@@ -695,6 +695,8 @@ class VmRenewForm(forms.Form): ...@@ -695,6 +695,8 @@ class VmRenewForm(forms.Form):
force = forms.BooleanField(required=False, label=_( force = forms.BooleanField(required=False, label=_(
"Set expiration times even if they are shorter than " "Set expiration times even if they are shorter than "
"the current value.")) "the current value."))
save = forms.BooleanField(required=False, label=_(
"Save selected lease."))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
choices = kwargs.pop('choices') choices = kwargs.pop('choices')
...@@ -706,6 +708,7 @@ class VmRenewForm(forms.Form): ...@@ -706,6 +708,7 @@ class VmRenewForm(forms.Form):
empty_label=None, label=_('Length'))) empty_label=None, label=_('Length')))
if len(choices) < 2: if len(choices) < 2:
self.fields['lease'].widget = HiddenInput() self.fields['lease'].widget = HiddenInput()
self.fields['save'].widget = HiddenInput()
@property @property
def helper(self): def helper(self):
......
...@@ -754,7 +754,7 @@ class RenewOperation(InstanceOperation): ...@@ -754,7 +754,7 @@ class RenewOperation(InstanceOperation):
required_perms = () required_perms = ()
concurrency_check = False concurrency_check = False
def _operation(self, activity, lease=None, force=False): def _operation(self, activity, lease=None, force=False, save=False):
suspend, delete = self.instance.get_renew_times(lease) suspend, delete = self.instance.get_renew_times(lease)
if (not force and suspend and self.instance.time_of_suspend and if (not force and suspend and self.instance.time_of_suspend and
suspend < self.instance.time_of_suspend): suspend < self.instance.time_of_suspend):
...@@ -768,6 +768,8 @@ class RenewOperation(InstanceOperation): ...@@ -768,6 +768,8 @@ class RenewOperation(InstanceOperation):
"in its delete time get earlier than before.")) "in its delete time get earlier than before."))
self.instance.time_of_suspend = suspend self.instance.time_of_suspend = suspend
self.instance.time_of_delete = delete self.instance.time_of_delete = delete
if save:
self.instance.lease = lease
self.instance.save() self.instance.save()
activity.result = create_readable(ugettext_noop( activity.result = create_readable(ugettext_noop(
"Renewed to suspend at %(suspend)s and destroy at %(delete)s."), "Renewed to suspend at %(suspend)s and destroy at %(delete)s."),
......
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