12318: Merge branch 'master' into 12318-update-libcloud-pin
[arvados.git] / apps / workbench / app / models / virtual_machine.rb
index 61b3b6b36173703a8a554b9e4083773dc0015788..a81d76fd798c979923fac2a26f6ca7617c72cb2a 100644 (file)
@@ -1,5 +1,30 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class VirtualMachine < ArvadosBase
+  attr_accessor :current_user_logins
+
   def self.creatable?
-    current_user.andand.is_admin
+    false
+  end
+
+  def attributes_for_display
+    super.append ['current_user_logins', @current_user_logins]
+  end
+
+  def editable_attributes
+    super - %w(current_user_logins)
+  end
+
+  def self.attribute_info
+    merger = ->(k,a,b) { a.merge(b, &merger) }
+    merger [nil,
+            {current_user_logins: {column_heading: "logins", type: 'array'}},
+            super]
+  end
+
+  def friendly_link_name lookup=nil
+    (hostname && !hostname.empty?) ? hostname : uuid
   end
 end