Short-circuts #readable_by when the user is admin.
[arvados.git] / services / api / app / models / link.rb
index 8e17ce697e52c16e1553b6a505297c1aa51ade6a..26e7183be385dba38da43b85eec02d6649311c6d 100644 (file)
@@ -8,17 +8,15 @@ class Link < ArvadosModel
   after_update :maybe_invalidate_permissions_cache
   after_create :maybe_invalidate_permissions_cache
   after_destroy :maybe_invalidate_permissions_cache
-
-  attr_accessor :head
-  attr_accessor :tail
+  attr_accessor :head_kind, :tail_kind
 
   api_accessible :user, extend: :common do |t|
     t.add :tail_uuid
     t.add :link_class
     t.add :name
     t.add :head_uuid
-    t.add :head, :if => :head
-    t.add :tail, :if => :tail
+    t.add :head_kind
+    t.add :tail_kind
     t.add :properties
   end
 
@@ -27,6 +25,18 @@ class Link < ArvadosModel
     super
   end
 
+  def head_kind
+    if k = ArvadosModel::resource_class_for_uuid(head_uuid)
+      k.kind
+    end
+  end
+
+  def tail_kind
+    if k = ArvadosModel::resource_class_for_uuid(tail_uuid)
+      k.kind
+    end
+  end
+
   protected
 
   def permission_to_attach_to_objects