Short-circuts #readable_by when the user is admin.
[arvados.git] / services / api / app / models / keep_disk.rb
index 3913077846e44665a01f85cb5ffee1bd026e27f4..77fc6278eba531f6baa1acf997044aaf893121c6 100644 (file)
@@ -4,10 +4,9 @@ class KeepDisk < ArvadosModel
   include CommonApiTemplate
   before_validation :ensure_ping_secret
 
-  api_accessible :superuser, :extend => :common do |t|
+  api_accessible :user, extend: :common do |t|
     t.add :node_uuid
     t.add :filesystem_uuid
-    t.add :ping_secret
     t.add :bytes_total
     t.add :bytes_free
     t.add :is_readable
@@ -19,6 +18,13 @@ class KeepDisk < ArvadosModel
     t.add :service_port
     t.add :service_ssl_flag
   end
+  api_accessible :superuser, :extend => :user do |t|
+    t.add :ping_secret
+  end
+
+  def foreign_key_attributes
+    super.reject { |a| a == "filesystem_uuid" }
+  end
 
   def ping(o)
     raise "must have :service_host and :ping_secret" unless o[:service_host] and o[:ping_secret]
@@ -29,7 +35,7 @@ class KeepDisk < ArvadosModel
     end
 
     @bypass_arvados_authorization = true
-    self.update_attributes(o.select { |k,v|
+    self.update_attributes!(o.select { |k,v|
                              [:service_host,
                               :service_port,
                               :service_ssl_flag,