2961: Changed index methods on some controllers to use render_index instead of
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 10 Jun 2014 13:08:38 +0000 (09:08 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 10 Jun 2014 13:08:38 +0000 (09:08 -0400)
super, to skip the default index query logic but still apply the tab partial
logic.

apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/controllers/folders_controller.rb
apps/workbench/app/controllers/groups_controller.rb
apps/workbench/app/controllers/jobs_controller.rb
apps/workbench/app/controllers/sessions_controller.rb

index b77ce8d14811f850441debf22acdefcfab22d4cd..65085a77ea5daedc787473728885b16bce9db5ad 100644 (file)
@@ -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
index f4188b45c072de6d6e08b82ef856a33a6a105ac9..064acc689babe5a39db7b3d2ce23cf8e36a05c9d 100644 (file)
@@ -89,7 +89,7 @@ class CollectionsController < ApplicationController
     end
     @request_url = request.url
 
-    super
+    render_index
   end
 
   def show_file_links
index e00608eb8d7a909b67f6a2af50afed737557cd00..10a5e45689e7e996ab83767c43048414634e5543 100644 (file)
@@ -75,7 +75,7 @@ class FoldersController < ApplicationController
       sorted_paths.call({'Shared with me' =>
                           buildtree.call(children_of, false)})
 
-    super
+    render_index
   end
 
   def choose
index 30cd1e35c8b8d8971b994d44c531d322cc71dcea..71327d132e7bd6238accf48236bc45194f90d5ab 100644 (file)
@@ -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
index dc31229189e9a7be5636eb38ec58f9aa510aec0e..51e27abd41234c088b5e232148d5bbadf8a2619d 100644 (file)
@@ -30,7 +30,7 @@ class JobsController < ApplicationController
     else
       @limit = 20
     end
-    super
+    render_index
   end
 
   def cancel
index abed6b68a7127e33fae06943025385f0bd43a7bc..591373b6c2c6526a85f26d5211ca8a94f1468ab0 100644 (file)
@@ -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