aboutsummaryrefslogtreecommitdiffstats
path: root/src/account/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/account/models.py')
-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