Fixed redirecting user to list vm page, if he requests for details of a vm whose id does not belong to him

This commit is contained in:
M.Ravi 2017-06-17 14:46:11 +05:30
parent 10b0e06aa1
commit bf99bd5edb

View file

@ -742,6 +742,12 @@ class VirtualMachineView(LoginRequiredMixin, View):
try:
vm = manager.get_vm(vm_id)
return vm
except WrongIdError:
messages.error(self.request,
_('We could not find the requested VM. Please \
contact Data Center Light Support.')
)
return None
except ConnectionRefusedError:
messages.error(self.request,
'We could not load your VM due to a backend connection \
@ -758,6 +764,8 @@ class VirtualMachineView(LoginRequiredMixin, View):
def get(self, request, *args, **kwargs):
vm = self.get_object()
if vm is None:
return redirect(reverse('hosting:virtual_machines'))
try:
serializer = VirtualMachineSerializer(vm)
context = {