diff --git a/hosting/static/hosting/js/virtual_machine_detail.js b/hosting/static/hosting/js/virtual_machine_detail.js index d6387dbc..711b486b 100644 --- a/hosting/static/hosting/js/virtual_machine_detail.js +++ b/hosting/static/hosting/js/virtual_machine_detail.js @@ -27,7 +27,7 @@ function VMTerminateSuccess($container, data) { $container.addClass('terminate-success') .find('.vm-item-lg').text(data.text); $container.find('.btn').remove(); - window.location = data.redirect; + $('#terminate-success').modal('show'); } function VMTerminateFail($container, data, text) { diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html index d0bfae47..9d77c31d 100644 --- a/hosting/templates/hosting/virtual_machine_detail.html +++ b/hosting/templates/hosting/virtual_machine_detail.html @@ -103,7 +103,7 @@ + + + {%endblock%} diff --git a/hosting/views.py b/hosting/views.py index acd7e67b..8356d5ad 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -961,7 +961,13 @@ class VirtualMachineView(LoginRequiredMixin, View): password=owner.password ) - vm_data = VirtualMachineSerializer(manager.get_vm(vm.id)).data + try: + vm_data = VirtualMachineSerializer(manager.get_vm(vm.id)).data + except BaseException: + return redirect( + reverse('hosting:virtual_machines', + kwargs={'pk': opennebula_vm_id}) + ) terminated = manager.delete_vm(vm.id) @@ -971,12 +977,10 @@ class VirtualMachineView(LoginRequiredMixin, View): else: for t in range(15): try: - manager.get_vm(self.kwargs.get('pk')) + manager.get_vm(opennebula_vm_id) except WrongIdError: response['status'] = True - response['redirect'] = self.get_success_url() response['text'] = ugettext('Terminated') - self.send_mail() break except BaseException: break