1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class Arvados::V1::UserAgreementsController < ApplicationController
6 before_action :admin_required, except: [:index, :sign, :signatures]
7 skip_before_action :find_object_by_uuid, only: [:sign, :signatures]
8 skip_before_action :render_404_if_no_object, only: [:sign, :signatures]
19 if not current_user.is_invited
20 # New users cannot see user agreements until/unless invited to
21 # use this installation.
25 uuids = Link.where("owner_uuid = ? and link_class = ? and name = ? and tail_uuid = ? and head_uuid like ?",
30 Collection.uuid_like_pattern).
32 @objects = Collection.where('uuid in (?)', uuids)
35 @response_resource_name = 'collection'
39 def self._signatures_method_description
40 "List all user agreement signature links from a user."
44 current_user_uuid = (current_user.andand.is_admin && params[:uuid]) ||
47 @objects = Link.where("owner_uuid = ? and link_class = ? and name = ? and tail_uuid = ? and head_uuid like ?",
52 Collection.uuid_like_pattern)
54 @response_resource_name = 'link'
58 def self._sign_method_description
59 "Create a signature link from the current user for a given user agreement."
63 current_user_uuid = current_user.uuid
65 @object = Link.create(link_class: 'signature',
67 tail_uuid: current_user_uuid,
68 head_uuid: params[:uuid])
87 raise ArgumentError.new \
88 "Manage user agreements via Collections and Links instead."