Merge branch '1977-provenance-report' of git.clinicalfuture.com:arvados into 1977...
[arvados.git] / services / api / app / controllers / arvados / v1 / user_agreements_controller.rb
index ac74f3d8d2fc98c4109324751444de9896b33e77..4ad959e86aae9079554c9f0e24d77c840dea7482 100644 (file)
@@ -1,21 +1,33 @@
 class Arvados::V1::UserAgreementsController < ApplicationController
   before_filter :admin_required, except: [:index, :sign, :signatures]
+  skip_before_filter :find_object_by_uuid, only: [:sign, :signatures]
+  skip_before_filter :render_404_if_no_object, only: [:sign, :signatures]
 
   def model_class
     Link
   end
 
+  def table_name
+    'links'
+  end
+
   def index
-    current_user_uuid = current_user.uuid
-    act_as_system_user do
-      uuids = Link.where(owner_uuid: system_user_uuid,
-                         link_class: 'signature',
-                         name: 'require',
-                         tail_kind: 'arvados#user',
-                         tail_uuid: system_user_uuid,
-                         head_kind: 'arvados#collection').
-        collect &:head_uuid
-      @objects = Collection.where('uuid in (?)', uuids)
+    if not current_user.is_invited
+      # New users cannot see user agreements until/unless invited to
+      # use this installation.
+      @objects = []
+    else
+      current_user_uuid = current_user.uuid
+      act_as_system_user do
+        uuids = Link.where(owner_uuid: system_user_uuid,
+                           link_class: 'signature',
+                           name: 'require',
+                           tail_kind: 'arvados#user',
+                           tail_uuid: system_user_uuid,
+                           head_kind: 'arvados#collection').
+          collect &:head_uuid
+        @objects = Collection.where('uuid in (?)', uuids)
+      end
     end
     @response_resource_name = 'collection'
     super
@@ -44,7 +56,7 @@ class Arvados::V1::UserAgreementsController < ApplicationController
                             tail_kind: 'arvados#user',
                             tail_uuid: current_user_uuid,
                             head_kind: 'arvados#collection',
-                            head_uuid: params[:id])
+                            head_uuid: params[:uuid])
     end
     show
   end