Merge branch 'master' into 3052-crunch-log-stdout
[arvados.git] / apps / workbench / app / models / link.rb
index 899a80022ced45b28ce618f2fc847f268550750a..271fa0f0103eac4e3197d417ffc31430285b6643 100644 (file)
@@ -2,6 +2,20 @@ class Link < ArvadosBase
   attr_accessor :head
   attr_accessor :tail
   def self.by_tail(t, opts={})
-    where(opts.merge :tail_kind => t.kind, :tail_uuid => t.uuid)
+    where(opts.merge :tail_uuid => t.uuid)
+  end
+
+  def default_name
+    self.class.resource_class_for_uuid(head_uuid).default_name rescue super
+  end
+
+  def self.permissions_for(thing)
+    if thing.respond_to? :uuid
+      uuid = thing.uuid
+    else
+      uuid = thing
+    end
+    result = arvados_api_client.api("permissions", "/#{uuid}")
+    arvados_api_client.unpack_api_response(result)
   end
 end