X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8acdf166ab8add0a62d4bfa3817c88cdc870d935..32dd80c96d67add6779a9ed4c522276424e049d9:/apps/workbench/app/controllers/virtual_machines_controller.rb diff --git a/apps/workbench/app/controllers/virtual_machines_controller.rb b/apps/workbench/app/controllers/virtual_machines_controller.rb index 9ccbfa6821..a62ba81b09 100644 --- a/apps/workbench/app/controllers/virtual_machines_controller.rb +++ b/apps/workbench/app/controllers/virtual_machines_controller.rb @@ -1,2 +1,22 @@ class VirtualMachinesController < ApplicationController + def index + @objects ||= model_class.all + @vm_logins = {} + if @objects.andand.first + Link.where(tail_uuid: current_user.uuid, + head_uuid: @objects.collect(&:uuid), + link_class: 'permission', + name: 'can_login'). + each do |perm_link| + if perm_link.properties.andand[:username] + @vm_logins[perm_link.head_uuid] ||= [] + @vm_logins[perm_link.head_uuid] << perm_link.properties[:username] + end + end + @objects.each do |vm| + vm.current_user_logins = @vm_logins[vm.uuid].andand.compact || [] + end + end + super + end end