Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / apps / workbench / app / controllers / virtual_machines_controller.rb
1 class VirtualMachinesController < ApplicationController
2   def index
3     @objects ||= model_class.all
4     @vm_logins = {}
5     if @objects.andand.first
6       Link.where(tail_uuid: current_user.uuid,
7                  head_uuid: @objects.collect(&:uuid),
8                  link_class: 'permission',
9                  name: 'can_login').
10         each do |perm_link|
11         if perm_link.properties.andand[:username]
12           @vm_logins[perm_link.head_uuid] ||= []
13           @vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
14         end
15       end
16       @objects.each do |vm|
17         vm.current_user_logins = @vm_logins[vm.uuid].andand.compact || []
18       end
19     end
20     super
21   end
22 end