Commit b4274949 by Őry Máté

one: renew renews both deadlines

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