From 8c012f8a9bc64add11920688abcd6981278cb0ea Mon Sep 17 00:00:00 2001 From: Parker Berberian Date: Thu, 13 Feb 2020 14:25:24 -0500 Subject: Fix Imports Fixes stale import statements. The dashboard can now come up and we can run our unit tests Change-Id: I7189afb2cd37aaa2492de065c236b6aa9a35de5b Signed-off-by: Parker Berberian --- src/dashboard/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/dashboard/utils.py') diff --git a/src/dashboard/utils.py b/src/dashboard/utils.py index af2461e..3d63366 100644 --- a/src/dashboard/utils.py +++ b/src/dashboard/utils.py @@ -1,3 +1,14 @@ +############################################################################## +# 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 + class AbstractModelQuery(): """ @@ -22,3 +33,10 @@ class AbstractModelQuery(): result = [] for model in cls.model_list: result += list(model.objects.filter(*args, **kwargs)) + + @classmethod + def get(cls, *args, **kwargs): + try: + return cls.filter(*args, **kwargs)[0] + except IndexError: + raise ObjectDoesNotExist() -- cgit 1.2.3-korg