aboutsummaryrefslogtreecommitdiffstats
path: root/src/account
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2020-06-23 20:58:26 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-06-23 20:58:26 +0000
commit2b15204ca0f8d9a51c3b4963db904d797ebb8186 (patch)
treed0d85f1307fa7005eab8757da4366ccddfb441f9 /src/account
parent6a41bf4f6f0b84e84293b7f2649ba60a9c78818f (diff)
parent03f767a2833293b7a0412eba9dce438a4b074b87 (diff)
Merge "Quick Booking Menu Resource Availibility"
Diffstat (limited to 'src/account')
-rw-r--r--src/account/models.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/account/models.py b/src/account/models.py
index 294e109..4aab306 100644
--- a/src/account/models.py
+++ b/src/account/models.py
@@ -10,9 +10,11 @@
from django.contrib.auth.models import User
from django.db import models
+from django.apps import apps
import json
import random
+from collections import Counter
class LabStatus(object):
"""
@@ -212,6 +214,12 @@ class Lab(models.Model):
key += random.choice(alphabet)
return key
+ def get_available_resources(self):
+ # Cannot import model normally due to ciruclar import
+ Server = apps.get_model('resource_inventory', 'Server') # TODO: Find way to import ResourceQuery
+ resources = [str(resource.profile) for resource in Server.objects.filter(lab=self, booked=False)]
+ return dict(Counter(resources))
+
def __str__(self):
return self.name