From 03f767a2833293b7a0412eba9dce438a4b074b87 Mon Sep 17 00:00:00 2001
From: ssmith <ssmith@iol.unh.edu>
Date: Wed, 17 Jun 2020 11:44:30 -0400
Subject: Quick Booking Menu Resource Availibility

Signed-off-by: Sean Smith <ssmith@iol.unh.edu>
Change-Id: I79f411af8996698d2c553185eed0221792a348d0
---
 src/account/models.py | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'src/account')

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
 
-- 
cgit