Redirect to my virtual machines page if any error

This commit is contained in:
M.Ravi 2017-09-29 21:53:02 +02:00
parent e6869612d8
commit 1dfe1d7cf8

View file

@ -1003,6 +1003,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
return redirect(reverse('hosting:virtual_machines')) return redirect(reverse('hosting:virtual_machines'))
elif self.request.is_ajax(): elif self.request.is_ajax():
return HttpResponse() return HttpResponse()
context = None
try: try:
serializer = VirtualMachineSerializer(vm) serializer = VirtualMachineSerializer(vm)
context = { context = {
@ -1012,7 +1013,11 @@ class VirtualMachineView(LoginRequiredMixin, View):
} }
except Exception as ex: except Exception as ex:
logger.debug("Exception generated {}".format(str(ex))) logger.debug("Exception generated {}".format(str(ex)))
pass messages.error(self.request,
_('We could not find the requested VM. Please '
'contact Data Center Light Support.')
)
return redirect(reverse('hosting:virtual_machines'))
return render(request, self.template_name, context) return render(request, self.template_name, context)