From 55bd42fe64707b43c8ec713c83fde5760b5e6a6b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 17 Mar 2020 14:50:14 +0100 Subject: [PATCH] List all VMs for admins --- uncloud/uncloud_vm/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/uncloud/uncloud_vm/views.py b/uncloud/uncloud_vm/views.py index cac743c..e1bbd22 100644 --- a/uncloud/uncloud_vm/views.py +++ b/uncloud/uncloud_vm/views.py @@ -85,7 +85,12 @@ class VMProductViewSet(ProductViewSet): serializer_class = VMProductSerializer def get_queryset(self): - return VMProduct.objects.filter(owner=self.request.user) + if self.request.user.is_superuser: + obj = VMProduct.objects.all() + else: + obj = VMProduct.objects.filter(owner=self.request.user) + + return obj # Use a database transaction so that we do not get half-created structure # if something goes wrong.