X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/16f704326f44fd1e5e5e60b936c9b5895d6a6ff8..c7d692a3f09d8116cc52591f8852c4e0d6e4ab3c:/apps/workbench/app/controllers/application_controller.rb diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 8d9e8578c5..f913a15ffe 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -11,19 +11,19 @@ class ApplicationController < ActionController::Base ERROR_ACTIONS = [:render_error, :render_not_found] - around_filter :thread_clear - around_filter :set_current_request_id - around_filter :set_thread_api_token + around_action :thread_clear + around_action :set_current_request_id + around_action :set_thread_api_token # Methods that don't require login should - # skip_around_filter :require_thread_api_token - around_filter :require_thread_api_token, except: ERROR_ACTIONS - before_filter :ensure_arvados_api_exists, only: [:index, :show] - before_filter :set_cache_buster - before_filter :accept_uuid_as_id_param, except: ERROR_ACTIONS - before_filter :check_user_agreements, except: ERROR_ACTIONS - before_filter :check_user_profile, except: ERROR_ACTIONS - before_filter :load_filters_and_paging_params, except: ERROR_ACTIONS - before_filter :find_object_by_uuid, except: [:create, :index, :choose] + ERROR_ACTIONS + # skip_around_action :require_thread_api_token + around_action :require_thread_api_token, except: ERROR_ACTIONS + before_action :ensure_arvados_api_exists, only: [:index, :show] + before_action :set_cache_buster + before_action :accept_uuid_as_id_param, except: ERROR_ACTIONS + before_action :check_user_agreements, except: ERROR_ACTIONS + before_action :check_user_profile, except: ERROR_ACTIONS + before_action :load_filters_and_paging_params, except: ERROR_ACTIONS + before_action :find_object_by_uuid, except: [:create, :index, :choose] + ERROR_ACTIONS theme :select_theme begin @@ -226,6 +226,7 @@ class ApplicationController < ActionController::Base end def index + @objects = nil if !defined?(@objects) find_objects_for_index if !@objects render_index end @@ -322,6 +323,7 @@ class ApplicationController < ActionController::Base end def choose + @objects = nil if !defined?(@objects) params[:limit] ||= 40 respond_to do |f| if params[:partial] @@ -353,6 +355,9 @@ class ApplicationController < ActionController::Base def update @updates ||= params[@object.resource_param_name.to_sym] + if @updates.is_a? ActionController::Parameters + @updates = @updates.to_unsafe_hash + end @updates.keys.each do |attr| if @object.send(attr).is_a? Hash if @updates[attr].is_a? String @@ -361,6 +366,9 @@ class ApplicationController < ActionController::Base if params[:merge] || params["merge_#{attr}".to_sym] # Merge provided Hash with current Hash, instead of # replacing. + if @updates[attr].is_a? ActionController::Parameters + @updates[attr] = @updates[attr].to_unsafe_hash + end @updates[attr] = @object.send(attr).with_indifferent_access. deep_merge(@updates[attr].with_indifferent_access) end @@ -536,7 +544,7 @@ class ApplicationController < ActionController::Base def accept_uuid_as_id_param - if params[:id] and params[:id].match /\D/ + if params[:id] and params[:id].match(/\D/) params[:uuid] = params.delete :id end end @@ -806,6 +814,7 @@ class ApplicationController < ActionController::Base helper_method :user_notifications def user_notifications + @errors = nil if !defined?(@errors) return [] if @errors or not current_user.andand.is_active or not Rails.configuration.show_user_notifications @notifications ||= @@notification_tests.map do |t| t.call(self, current_user) @@ -917,7 +926,7 @@ class ApplicationController < ActionController::Base helper_method :my_starred_projects def my_starred_projects user - return if @starred_projects + return if defined?(@starred_projects) && @starred_projects links = Link.filter([['tail_uuid', '=', user.uuid], ['link_class', '=', 'star'], ['head_uuid', 'is_a', 'arvados#group']]).select(%w(head_uuid)) @@ -932,7 +941,7 @@ class ApplicationController < ActionController::Base # That is: get toplevel projects under home, get subprojects of # these projects, and so on until we hit the limit. def my_wanted_projects(user, page_size=100) - return @my_wanted_projects if @my_wanted_projects + return @my_wanted_projects if defined?(@my_wanted_projects) && @my_wanted_projects from_top = [] uuids = [user.uuid] @@ -963,7 +972,7 @@ class ApplicationController < ActionController::Base end def build_my_wanted_projects_tree(user, page_size=100) - return @my_wanted_projects_tree if @my_wanted_projects_tree + return @my_wanted_projects_tree if defined?(@my_wanted_projects_tree) && @my_wanted_projects_tree parent_of = {user.uuid => 'me'} my_wanted_projects(user, page_size).each do |ob| @@ -978,10 +987,10 @@ class ApplicationController < ActionController::Base children_of[parent_of[ob.uuid]] ||= [] children_of[parent_of[ob.uuid]] << ob end - buildtree = lambda do |children_of, root_uuid=false| + buildtree = lambda do |chldrn_of, root_uuid=false| tree = {} - children_of[root_uuid].andand.each do |ob| - tree[ob] = buildtree.call(children_of, ob.uuid) + chldrn_of[root_uuid].andand.each do |ob| + tree[ob] = buildtree.call(chldrn_of, ob.uuid) end tree end