Merge remote-tracking branch 'remotes/origin/1636-inactive-user' into 1678-new-user...
[arvados.git] / apps / workbench / app / controllers / users_controller.rb
1 class UsersController < ApplicationController
2   skip_before_filter :find_object_by_uuid, :only => :welcome
3   skip_around_filter :thread_with_api_token, :only => :welcome
4   around_filter :thread_with_optional_api_token, :only => :welcome
5
6   def welcome
7     if current_user
8       redirect_to home_user_path(current_user.uuid)
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_jobs = Job.
17       limit(10).
18       order('created_at desc').
19       where(created_by: current_user.uuid)
20
21     # A Tutorial is a Link which has link_class "resources" and name
22     # "wants", and is owned by the Tutorials Group (i.e., named
23     # "Arvados Tutorials" and owned by the system user).
24     @tutorial_group = Group.where(owner_uuid: User.system.uuid,
25                                   name: 'Arvados Tutorials').first
26     if @tutorial_group
27       @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
28                                    link_class: 'resources',
29                                    name: 'wants')
30     else
31       @tutorial_links = []
32     end
33     @tutorial_complete = {
34       'Run a job' => @my_last_job
35     }
36   end
37 end