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:
commit
0cbd3aa666
1 changed files with 8 additions and 0 deletions
|
@ -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 = {
|
||||||
|
|
Loading…
Reference in a new issue