add default select_by_user to plcorebase, hunt down and destroy select_by_user methods in other classes that were redundant with the new default
diff --git a/planetstack/core/models/flavor.py b/planetstack/core/models/flavor.py
index 84a5427..27b2642 100644
--- a/planetstack/core/models/flavor.py
+++ b/planetstack/core/models/flavor.py
@@ -19,10 +19,6 @@
def __unicode__(self): return u'%s' % (self.name)
- @staticmethod
- def select_by_user(user):
- return Flavor.objects.all()
-
""" FlavorParameterType and FlavorParameter are below for completeness sake,
waiting for the day we might want to add parameters to flavors.
diff --git a/planetstack/core/models/network.py b/planetstack/core/models/network.py
index 1010cae..51cc0c8 100644
--- a/planetstack/core/models/network.py
+++ b/planetstack/core/models/network.py
@@ -24,10 +24,6 @@
def __unicode__(self): return u'%s' % (self.name)
- @staticmethod
- def select_by_user(user):
- return NetworkTemplate.objects.all()
-
class Network(PlCoreBase):
name = models.CharField(max_length=32)
template = models.ForeignKey(NetworkTemplate)
diff --git a/planetstack/core/models/node.py b/planetstack/core/models/node.py
index 56aee68..9271268 100644
--- a/planetstack/core/models/node.py
+++ b/planetstack/core/models/node.py
@@ -15,7 +15,3 @@
def __unicode__(self): return u'%s' % (self.name)
- @staticmethod
- def select_by_user(user):
- qs = Node.objects.all()
- return qs
diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py
index 51049a4..2ad6f76 100644
--- a/planetstack/core/models/plcorebase.py
+++ b/planetstack/core/models/plcorebase.py
@@ -149,7 +149,7 @@
if not silent:
notify_observer()
- self.__initial = self._dict
+ self._initial = self._dict
def save_by_user(self, user, *args, **kwds):
if not self.can_update(user):
@@ -166,6 +166,12 @@
raise PermissionDenied("You do not have permission to delete %s objects" % self.__class__.__name__)
self.delete(*args, **kwds)
+ @classmethod
+ def select_by_user(cls, user):
+ # This should be overridden by descendant classes that want to perform
+ # filtering of visible objects by user.
+ return cls.objects.all()
+
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 160b426..9f183b5 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -216,10 +216,6 @@
def __unicode__(self): return u'%s' % (self.name)
- @staticmethod
- def select_by_user(user):
- return Deployment.objects.all()
-
class DeploymentRole(PlCoreBase):
#objects = DeploymentLinkManager()
#deleted_objects = DeploymentLinkDeletionManager()
@@ -267,10 +263,6 @@
deployment = models.ForeignKey(Deployment)
tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")
- @staticmethod
- def select_by_user(user):
- return SiteDeployments.objects.all()
-
#class Meta:
# db_table = 'core_site_deployments'
# #auto_created = Site