diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2020-03-03 12:30:36 -0500 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2020-03-16 09:18:31 -0400 |
commit | b360e0e417f787e0266268596d630b87e88283d1 (patch) | |
tree | 64e6812e816b22f3ee4127113071966c0d30e061 /src/resource_inventory | |
parent | 4940cda1806aa13591485b996264ddc887202d35 (diff) |
Fixing and adding tests for the new resource models.
Change-Id: I4dd0569411b415a3e8a8de43d4b99e927e5b7821
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/resource_inventory')
-rw-r--r-- | src/resource_inventory/resource_manager.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/resource_inventory/resource_manager.py b/src/resource_inventory/resource_manager.py index e14218b..c8b2b05 100644 --- a/src/resource_inventory/resource_manager.py +++ b/src/resource_inventory/resource_manager.py @@ -7,11 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## import re +from django.db.models import Q from dashboard.exceptions import ResourceAvailabilityException from resource_inventory.models import ( ResourceBundle, + ResourceTemplate, Network, Vlan, PhysicalNetwork, @@ -31,6 +33,11 @@ class ResourceManager: ResourceManager.instance = ResourceManager() return ResourceManager.instance + def getAvailableResourceTemplates(self, lab, user): + templates = ResourceTemplate.objects.filter(lab=lab) + templates.filter(Q(owner=user) | Q(public=True)) + return templates + def templateIsReservable(self, resource_template): """ Check if the required resources to reserve this template is available. |