fix up collections index/show
[arvados.git] / apps / workbench / app / controllers / users_controller.rb
1 class UsersController < ApplicationController
2   skip_before_filter :find_object_by_uuid, :only => :welcome
3
4   def welcome
5     if current_user
6       redirect_to home_user_path(current_user.uuid)
7     else
8       redirect_to $arvados_api_client.arvados_login_url(return_to: request.url)
9     end
10   end
11
12   def home
13     @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid)
14     @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login')
15     @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write')
16     @my_last_job = Job.
17       limit(1).
18       order(:created_at).
19       where(created_by: current_user.uuid).
20       last
21
22     # A Tutorial is a Link which has link_class "resources" and name
23     # "wants", and is owned by the Tutorials Group (i.e., named
24     # "Arvados Tutorials" and owned by the system user).
25     @tutorial_group = Group.where(owner_uuid: User.system.uuid,
26                                   name: 'Arvados Tutorials').first
27     if @tutorial_group
28       @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
29                                    link_class: 'resources',
30                                    name: 'wants')
31     else
32       @tutorial_links = []
33     end
34     @tutorial_complete = {
35       'Run a job' => @my_last_job
36     }
37   end
38 end