diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2020-02-06 12:59:51 -0500 |
---|---|---|
committer | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2020-02-12 13:23:17 -0500 |
commit | f5cdab1569b26df0c7ffc3df1529f095116fd13a (patch) | |
tree | 0905a58a36b5be4a38613d1cb5834ec2e4d5e27f /src/workflow/forms.py | |
parent | 80f9bb0bb514133363bd0a40edb8b10ddb8d3a51 (diff) |
Modifies Resource Models for ongoing refactor
Change-Id: Ice88f53135f57aca8e2de4d69274e7d490f981a4
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/workflow/forms.py')
-rw-r--r-- | src/workflow/forms.py | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/workflow/forms.py b/src/workflow/forms.py index f7a20eb..37bc390 100644 --- a/src/workflow/forms.py +++ b/src/workflow/forms.py @@ -300,7 +300,7 @@ class FormUtils: else: multiple_hosts = false labs = {} - hosts = {} + resources = {} items = {} neighbors = {} for lab in Lab.objects.all(): @@ -311,24 +311,21 @@ class FormUtils: 'description': lab.description, 'selected': false, 'selectable': true, - 'follow': false, + 'follow': multiple_hosts, 'multiple': false, 'class': 'lab' } - if multiple_hosts: - # "follow" this lab node to discover more hosts if allowed - lab_node['follow'] = true items[lab_node['id']] = lab_node neighbors[lab_node['id']] = [] labs[lab_node['id']] = lab_node - for host in lab.hostprofiles.all(): - host_node = { + for template in lab.resourcetemplates.all(): + resource_node = { 'form': {"name": "host_name", "type": "text", "placeholder": "hostname"}, - 'id': "host_" + str(host.id), - 'model_id': host.id, - 'name': host.name, - 'description': host.description, + 'id': "resource_" + str(template.id), + 'model_id': template.id, + 'name': template.name, + 'description': template.description, 'selected': false, 'selectable': true, 'follow': false, @@ -336,15 +333,15 @@ class FormUtils: 'class': 'host' } if multiple_hosts: - host_node['values'] = [] # place to store multiple values - items[host_node['id']] = host_node - neighbors[lab_node['id']].append(host_node['id']) - if host_node['id'] not in neighbors: - neighbors[host_node['id']] = [] - neighbors[host_node['id']].append(lab_node['id']) - hosts[host_node['id']] = host_node - - display_objects = [("lab", labs.values()), ("host", hosts.values())] + resource_node['values'] = [] # place to store multiple values + items[resource_node['id']] = resource_node + neighbors[lab_node['id']].append(resource_node['id']) + if resource_node['id'] not in neighbors: + neighbors[resource_node['id']] = [] + neighbors[resource_node['id']].append(lab_node['id']) + resources[resource_node['id']] = resource_node + + display_objects = [("lab", labs.values()), ("resource", resources.values())] context = { 'display_objects': display_objects, |