From 84dfaf67eca08a0a7a214ad010013afd1b3db7b1 Mon Sep 17 00:00:00 2001
From: Jeff Ohrstrom <johrstrom@hotmail.com>
Date: Thu, 14 Jan 2021 12:13:35 -0500
Subject: [PATCH] change account to be a select with only valid group options

---
 form.yml => form.yml.erb | 15 ++++++++++++---
 submit.yml.erb           |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)
 rename form.yml => form.yml.erb (84%)

diff --git a/form.yml b/form.yml.erb
similarity index 84%
rename from form.yml
rename to form.yml.erb
index 6504316..6c7786e 100644
--- a/form.yml
+++ b/form.yml.erb
@@ -1,9 +1,14 @@
+<%-
+  groups = OodSupport::User.new.groups.sort_by(&:id).tap { |groups|
+    groups.unshift(groups.delete(OodSupport::Process.group))
+  }.map(&:name).grep(/^P./)
+-%>
 ---
 cluster:
   - "owens"
 form:
   - version
-  - bc_account
+  - account
   - bc_num_hours
   - bc_num_slots
   - num_cores
@@ -25,9 +30,13 @@ attributes:
   bc_num_slots: "1"
   bc_vnc_resolution:
     required: true
-  bc_account:
+  account:
     label: "Project"
-    help: "You can leave this blank if **not** in multiple projects."
+    widget: select
+    options:
+      <%- groups.each do |group| %>
+      - "<%= group %>"
+      <%- end %>
   node_type:
     widget: select
     label: "Node type"
diff --git a/submit.yml.erb b/submit.yml.erb
index 475347e..e89017d 100644
--- a/submit.yml.erb
+++ b/submit.yml.erb
@@ -17,6 +17,7 @@
 batch_connect:
   template: vnc
 script:
+  accounting_id: "<%= account %>"
   native:
   <%- slurm_args.each do |arg| %>
     - "<%= arg %>"
-- 
GitLab