Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/core/models/controlleruser.py b/xos/core/models/controlleruser.py
index 6b11b24..1031e12 100644
--- a/xos/core/models/controlleruser.py
+++ b/xos/core/models/controlleruser.py
@@ -26,7 +26,7 @@
if user.is_admin:
qs = ControllerUser.objects.all()
else:
- users = Users.select_by_user(user)
+ users = User.select_by_user(user)
qs = ControllerUser.objects.filter(user__in=users)
return qs
diff --git a/xos/core/models/network.py b/xos/core/models/network.py
index fe60fce..2bdf17f 100644
--- a/xos/core/models/network.py
+++ b/xos/core/models/network.py
@@ -7,6 +7,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.exceptions import ValidationError
+from django.db.models import Q
# If true, then IP addresses will be allocated by the model. If false, then
# we will assume the observer handles it.
@@ -203,7 +204,8 @@
qs = NetworkSlice.objects.all()
else:
slice_ids = [s.id for s in Slice.select_by_user(user)]
- qs = NetworkSlice.objects.filter(id__in=slice_ids)
+ network_ids = [network.id for network in Network.select_by_user(user)]
+ qs = NetworkSlice.objects.filter(Q(slice__in=slice_ids) | Q(network__in=network_ids))
return qs
class Port(PlCoreBase):
@@ -246,8 +248,11 @@
if user.is_admin:
qs = Port.objects.all()
else:
- instance_ids = [s.id for s in Port.select_by_user(user)]
- qs = Port.objects.filter(id__in=instance_ids)
+ instances = Instance.select_by_user(user)
+ instance_ids = [instance.id for instance in instances]
+ networks = Network.select_by_user(user)
+ network_ids = [network.id for network in networks]
+ qs = Port.objects.filter(Q(instance__in=instance_ids) | Q(network__in=network_ids))
return qs
class Router(PlCoreBase):