7709: Merge branch 'master' into 7709-api-rails4
[arvados.git] / apps / workbench / app / controllers / users_controller.rb
index 2f513655b6e9424374f0ed90d559acc9a711d236..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)
@@ -208,9 +209,6 @@ class UsersController < ApplicationController
         if params['openid_prefix'] && params['openid_prefix'].size>0
           setup_params[:openid_prefix] = params['openid_prefix']
         end
-        if params['repo_name'] && params['repo_name'].size>0
-          setup_params[:repo_name] = params['repo_name']
-        end
         if params['vm_uuid'] && params['vm_uuid'].size>0
           setup_params[:vm_uuid] = params['vm_uuid']
         end
@@ -258,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).
@@ -283,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|
@@ -296,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