7709: Merge branch 'master' into 7709-api-rails4
[arvados.git] / apps / workbench / app / controllers / users_controller.rb
index 4cf1fffc09bb3e3a815311f86c2550bbe16e5f3d..1a1c5f802152ffe4cdb7ff009fce0bb02c70cbc1 100644 (file)
@@ -102,6 +102,7 @@ class UsersController < ApplicationController
         filter([[:object_uuid, '=', u.uuid],
                 [:event_type, '=', 'user-storage-report']]).
         order(:created_at => :desc).
+        with_count('none').
         limit(1)
       storage_log.each do |log_entry|
         # We expect this block to only execute once since we specified limit(1)
@@ -255,15 +256,14 @@ class UsersController < ApplicationController
     end
   end
 
-  def manage_account
-    # repositories current user can read / write
+  def repositories
     repo_links = Link.
       filter([['head_uuid', 'is_a', 'arvados#repository'],
               ['tail_uuid', '=', current_user.uuid],
               ['link_class', '=', 'permission'],
              ])
 
-    owned_repositories = Repository.where(owner_uuid: current_user.uuid)
+    owned_repositories = Repository.where(owner_uuid: @object.uuid)
 
     @my_repositories = (Repository.where(uuid: repo_links.collect(&:head_uuid)) |
                         owned_repositories).
@@ -280,10 +280,11 @@ class UsersController < ApplicationController
     owned_repositories.each do |repo|
       @repo_writable[repo.uuid] = 'can_manage'
     end
+  end
 
-    # virtual machines the current user can login into
+  def virtual_machines
     @my_vm_logins = {}
-    Link.where(tail_uuid: current_user.uuid,
+    Link.where(tail_uuid: @object.uuid,
                link_class: 'permission',
                name: 'can_login').
           each do |perm_link|
@@ -293,13 +294,10 @@ class UsersController < ApplicationController
             end
           end
     @my_virtual_machines = VirtualMachine.where(uuid: @my_vm_logins.keys)
+  end
 
-    # current user's ssh keys
-    @my_ssh_keys = AuthorizedKey.where(key_type: 'SSH', owner_uuid: current_user.uuid)
-
-    respond_to do |f|
-      f.html { render template: 'users/manage_account' }
-    end
+  def ssh_keys
+    @my_ssh_keys = AuthorizedKey.where(key_type: 'SSH', owner_uuid: @object.uuid)
   end
 
   def add_ssh_key_popup