summaryrefslogtreecommitdiffstats
path: root/src/dashboard
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2020-02-06 12:59:51 -0500
committerSawyer Bergeron <sbergeron@iol.unh.edu>2020-02-12 13:23:17 -0500
commitf5cdab1569b26df0c7ffc3df1529f095116fd13a (patch)
tree0905a58a36b5be4a38613d1cb5834ec2e4d5e27f /src/dashboard
parent80f9bb0bb514133363bd0a40edb8b10ddb8d3a51 (diff)
Modifies Resource Models for ongoing refactor
Change-Id: Ice88f53135f57aca8e2de4d69274e7d490f981a4 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/dashboard')
-rw-r--r--src/dashboard/utils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/dashboard/utils.py b/src/dashboard/utils.py
new file mode 100644
index 0000000..af2461e
--- /dev/null
+++ b/src/dashboard/utils.py
@@ -0,0 +1,24 @@
+
+class AbstractModelQuery():
+ """
+ This is a class made for querying abstract models.
+
+ This class is itself abstract. create subclasses to
+ query your own abstract models.
+ """
+
+ model_list = []
+
+ @classmethod
+ def filter(cls, *args, **kwargs):
+ """
+ Query all concrete model classes.
+
+ Iterates over the model list and returns a list of all
+ matching models from the classes given.
+ Filter queries are given here as normal and are passed into the Django ORM
+ for each concrete model
+ """
+ result = []
+ for model in cls.model_list:
+ result += list(model.objects.filter(*args, **kwargs))