Merge pull request #349 from pcoder/bug/3416/error_vm_id_change

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:
Pcoder 2017-06-18 17:12:52 +02:00 committed by GitHub
commit 0cbd3aa666

View file

@ -742,6 +742,12 @@ class VirtualMachineView(LoginRequiredMixin, View):
try: try:
vm = manager.get_vm(vm_id) vm = manager.get_vm(vm_id)
return vm 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: except ConnectionRefusedError:
messages.error(self.request, messages.error(self.request,
'We could not load your VM due to a backend connection \ '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): def get(self, request, *args, **kwargs):
vm = self.get_object() vm = self.get_object()
if vm is None:
return redirect(reverse('hosting:virtual_machines'))
try: try:
serializer = VirtualMachineSerializer(vm) serializer = VirtualMachineSerializer(vm)
context = { context = {