aboutsummaryrefslogtreecommitdiffstats
path: root/src/dashboard/utils.py
diff options
context:
space:
mode:
authorGergely Csatari <gergely.csatari@nokia.com>2023-10-26 10:33:28 +0300
committerGergely Csatari <gergely.csatari@nokia.com>2023-10-26 10:34:28 +0300
commit2ec0d7b9f5c1354977b821c6b06c24a3ffa13142 (patch)
tree6e449d92ddfc880ed007e9d8a8f25bda8fc7cb0f /src/dashboard/utils.py
parent0d3dd290aa6e7f39e7b0b3cbe448b6622f924240 (diff)
Removing project content and adding a noteHEADmaster
that the development continues in GitHub Change-Id: I25c58a679dbf92b2367d826429b7cda936bf9f0e Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>
Diffstat (limited to 'src/dashboard/utils.py')
-rw-r--r--src/dashboard/utils.py52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/dashboard/utils.py b/src/dashboard/utils.py
deleted file mode 100644
index 97c9ac7..0000000
--- a/src/dashboard/utils.py
+++ /dev/null
@@ -1,52 +0,0 @@
-##############################################################################
-# Copyright (c) 2020 Parker Berberian and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-from django.core.exceptions import (ObjectDoesNotExist, MultipleObjectsReturned)
-
-
-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))
-
- return result
-
- @classmethod
- def get(cls, *args, **kwargs):
- """
- Gets a single matching resource
- Throws ObjectDoesNotExist if none found matching, or MultipleObjectsReturned if
- the query does not narrow to a single object
- """
- try:
- ls = cls.filter(*args, **kwargs)
- if len(ls) > 1:
- raise MultipleObjectsReturned()
- return cls.filter(*args, **kwargs)[0]
- except IndexError:
- raise ObjectDoesNotExist()