Disable deployment filtering if the backend_type config option is not set
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 6fe40a6..af57ed2 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -13,10 +13,16 @@
class DeploymentLinkDeletionManager(PlCoreBaseDeletionManager):
def get_queryset(self):
parent=super(DeploymentLinkDeletionManager, self)
- if hasattr(parent, "get_queryset"):
- return parent.get_queryset().filter(Q(deployment__backend_type=config.observer_backend_type)|Q(backend_type=None))
+ try:
+ backend_type = config.observer_backend_type
+ except AttributeError:
+ backend_type = None
+
+ parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
+ if (backend_type):
+ return parent_queryset.filter(Q(deployment__backend_type=config.observer_backend_type)|Q(backend_type=None))
else:
- return parent.get_queryset().filter(Q(deployment__backend_type=config.observer_backend_type)|Q(backend_type=None))
+ return parent_queryset
# deprecated in django 1.7 in favor of get_queryset().
def get_query_set(self):
@@ -26,10 +32,18 @@
class DeploymentDeletionManager(PlCoreBaseDeletionManager):
def get_queryset(self):
parent=super(DeploymentDeletionManager, self)
- if hasattr(parent, "get_queryset"):
- return parent.get_queryset().filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
+
+ try:
+ backend_type = config.observer_backend_type
+ except AttributeError:
+ backend_type = None
+
+ parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
+
+ if backend_type:
+ return parent_queryset.filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
else:
- return parent.get_queryset().filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
+ return parent_queryset
# deprecated in django 1.7 in favor of get_queryset().
def get_query_set(self):
@@ -38,10 +52,18 @@
class DeploymentLinkManager(PlCoreBaseManager):
def get_queryset(self):
parent=super(DeploymentLinkManager, self)
- if hasattr(parent, "get_queryset"):
- return parent.get_queryset().filter(Q(deployment__backend_type=config.observer_backend_type)|Q(backend_type=None))
+
+ try:
+ backend_type = config.observer_backend_type
+ except AttributeError:
+ backend_type = None
+
+ parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
+
+ if backend_type:
+ return parent_queryset.filter(Q(deployment__backend_type=config.observer_backend_type)|Q(backend_type=None))
else:
- return parent.get_queryset().filter(Q(deployment__backend_type=config.observer_backend_type)|Q(backend_type=None))
+ return parent_queryset
# deprecated in django 1.7 in favor of get_queryset().
def get_query_set(self):
@@ -51,10 +73,18 @@
class DeploymentManager(PlCoreBaseManager):
def get_queryset(self):
parent=super(DeploymentManager, self)
- if hasattr(parent, "get_queryset"):
- return parent.get_queryset().filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
+
+ try:
+ backend_type = config.observer_backend_type
+ except AttributeError:
+ backend_type = None
+
+ parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
+
+ if backend_type:
+ return parent_queryset.filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
else:
- return parent.get_queryset().filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
+ return parent_queryset.filter(Q(backend_type=config.observer_backend_type)|Q(backend_type=None))
# deprecated in django 1.7 in favor of get_queryset().
def get_query_set(self):