Commit b4274949 by Őry Máté

one: renew renews both deadlines

parent 7774d21c
......@@ -629,12 +629,12 @@ class Instance(models.Model):
self._change_state("POWEROFF")
def restart(self):
self._change_state("RESET")
def renew(self, which):
if which == 'suspend':
def renew(self, which='both'):
if which in ['suspend', 'both']:
self.time_of_suspend = self.share.get_type()['suspendx']
elif which == 'delete':
if which in ['delete', 'both']:
self.time_of_delete = self.share.get_type()['deletex']
else:
if not (which in ['suspend', 'delete', 'both']):
raise ValueError('No such expiration type.')
self.save()
def save_as(self):
......
......@@ -515,7 +515,7 @@ def vm_resume(request, iid, *args, **kwargs):
@require_POST
def vm_renew(request, which, iid, *args, **kwargs):
try:
get_object_or_404(Instance, id=iid, owner=request.user).renew(which)
get_object_or_404(Instance, id=iid, owner=request.user).renew()
messages.success(request, _('Virtual machine is successfully renewed.'))
except:
messages.error(request, _('Failed to renew virtual machine.'))
......
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