From bf99bd5edb5a3509300f7550df28b87e0501a6ed Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Sat, 17 Jun 2017 14:46:11 +0530 Subject: [PATCH] Fixed redirecting user to list vm page, if he requests for details of a vm whose id does not belong to him --- hosting/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hosting/views.py b/hosting/views.py index 87d5bad0..45e23df4 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -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 = {