aboutsummaryrefslogtreecommitdiffstats
path: root/src/account
diff options
context:
space:
mode:
authorssmith <ssmith@iol.unh.edu>2020-06-17 11:44:30 -0400
committerssmith <ssmith@iol.unh.edu>2020-06-23 12:26:07 -0400
commit03f767a2833293b7a0412eba9dce438a4b074b87 (patch)
treea34ebe7451ed7a81ae4a60943071125556a025f5 /src/account
parentf96012fae9a106228ad80671a8c66476834a50db (diff)
Quick Booking Menu Resource Availibility
Signed-off-by: Sean Smith <ssmith@iol.unh.edu> Change-Id: I79f411af8996698d2c553185eed0221792a348d0
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