From 468a80200c8ef3e4a56700714e9af537d87a20bc Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 10 Jun 2014 09:08:38 -0400 Subject: [PATCH] 2961: Changed index methods on some controllers to use render_index instead of super, to skip the default index query logic but still apply the tab partial logic. --- .../app/controllers/application_controller.rb | 30 +++++++++++-------- .../app/controllers/collections_controller.rb | 2 +- .../app/controllers/folders_controller.rb | 2 +- .../app/controllers/groups_controller.rb | 2 +- .../app/controllers/jobs_controller.rb | 2 +- .../app/controllers/sessions_controller.rb | 4 ++- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index b77ce8d148..65085a77ea 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -63,6 +63,22 @@ class ApplicationController < ActionController::Base self.render_error status: 404 end + def render_index + respond_to do |f| + f.json { render json: @objects } + f.html { + if params['tab_pane'] + comparable = self.respond_to? :compare + render(partial: 'show_' + params['tab_pane'].downcase, + locals: { comparable: comparable, objects: @objects }) + else + render + end + } + f.js { render } + end + end + def index @limit ||= 200 if params[:limit] @@ -85,19 +101,7 @@ class ApplicationController < ActionController::Base @objects ||= model_class @objects = @objects.filter(@filters).limit(@limit).offset(@offset).all - respond_to do |f| - f.json { render json: @objects } - f.html { - if params['tab_pane'] - comparable = self.respond_to? :compare - render(partial: 'show_' + params['tab_pane'].downcase, - locals: { comparable: comparable, objects: @objects }) - else - render - end - } - f.js { render } - end + render_index end def show diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index f4188b45c0..064acc689b 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -89,7 +89,7 @@ class CollectionsController < ApplicationController end @request_url = request.url - super + render_index end def show_file_links diff --git a/apps/workbench/app/controllers/folders_controller.rb b/apps/workbench/app/controllers/folders_controller.rb index e00608eb8d..10a5e45689 100644 --- a/apps/workbench/app/controllers/folders_controller.rb +++ b/apps/workbench/app/controllers/folders_controller.rb @@ -75,7 +75,7 @@ class FoldersController < ApplicationController sorted_paths.call({'Shared with me' => buildtree.call(children_of, false)}) - super + render_index end def choose diff --git a/apps/workbench/app/controllers/groups_controller.rb b/apps/workbench/app/controllers/groups_controller.rb index 30cd1e35c8..71327d132e 100644 --- a/apps/workbench/app/controllers/groups_controller.rb +++ b/apps/workbench/app/controllers/groups_controller.rb @@ -4,7 +4,7 @@ class GroupsController < ApplicationController @group_uuids = @groups.collect &:uuid @links_from = Link.where link_class: 'permission', tail_uuid: @group_uuids @links_to = Link.where link_class: 'permission', head_uuid: @group_uuids - super + render_index end def show diff --git a/apps/workbench/app/controllers/jobs_controller.rb b/apps/workbench/app/controllers/jobs_controller.rb index dc31229189..51e27abd41 100644 --- a/apps/workbench/app/controllers/jobs_controller.rb +++ b/apps/workbench/app/controllers/jobs_controller.rb @@ -30,7 +30,7 @@ class JobsController < ApplicationController else @limit = 20 end - super + render_index end def cancel diff --git a/apps/workbench/app/controllers/sessions_controller.rb b/apps/workbench/app/controllers/sessions_controller.rb index abed6b68a7..591373b6c2 100644 --- a/apps/workbench/app/controllers/sessions_controller.rb +++ b/apps/workbench/app/controllers/sessions_controller.rb @@ -2,12 +2,14 @@ class SessionsController < ApplicationController skip_around_filter :thread_with_mandatory_api_token, :only => [:destroy, :index] skip_around_filter :thread_with_optional_api_token, :only => [:destroy, :index] skip_before_filter :find_object_by_uuid, :only => [:destroy, :index] + def destroy session.clear redirect_to arvados_api_client.arvados_logout_url(return_to: root_url) end + def index redirect_to root_url if session[:arvados_api_token] - super + render_index end end -- 2.30.2