remove error msg on successful termination

This commit is contained in:
Arvind Tiwari 2017-09-15 17:20:42 +05:30
parent 0c3f605735
commit 77f2454e3c
2 changed files with 16 additions and 9 deletions

View file

@ -1,13 +1,15 @@
function VMTerminateStatus($container, url) {
$.get(url)
.done(function(data) {
$.ajax({
url: url,
dataType: 'json',
success: function(data) {
VMTerminateSuccess($container, data);
},
error: function() {
setTimeout(function(){
VMTerminateStatus($container, url);
}, 4000);
})
.fail(function(data) {
VMTerminateSuccess($container, data)
window.location.reload(true);
}
});
}
@ -25,6 +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;
}
function VMTerminateFail($container, data, text) {
@ -50,7 +53,6 @@ $(document).ready(function() {
console.log("success", data);
if (data.status == true) {
VMTerminateSuccess($container, data);
window.location = data.redirect;
} else {
if ('text' in data) {
VMTerminateFail($container, data, text);

View file

@ -926,9 +926,14 @@ class VirtualMachineView(LoginRequiredMixin, View):
if self.request.is_ajax():
storage = messages.get_messages(request)
storage.used = True
raise Http404()
return HttpResponse(
json.dumps({'redirect': self.get_success_url()}),
content_type="application/json"
)
else:
return redirect(reverse('hosting:virtual_machines'))
elif self.request.is_ajax():
return HttpResponse()
try:
serializer = VirtualMachineSerializer(vm)
context = {