refactoring
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
helper :pagination
|
||||
before_filter :set_current_user
|
||||
after_filter :reset_current_user
|
||||
before_filter :initialize_cookies
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class PoolsPostsController < ApplicationController
|
||||
class PoolElementsController < ApplicationController
|
||||
respond_to :html, :xml, :json, :js
|
||||
before_filter :member_only
|
||||
|
||||
def create
|
||||
@pool = Pool.find_by_name(params[:pool_name]) || Pool.find(params[:pool_id])
|
||||
@post = Post.find(params[:post_id])
|
||||
@pool.add_post!(@post)
|
||||
@pool.add!(@post)
|
||||
append_pool_to_session(@pool)
|
||||
respond_with(@pool, :location => pool_path(@pool))
|
||||
end
|
||||
@@ -13,7 +13,7 @@ class PoolsPostsController < ApplicationController
|
||||
def destroy
|
||||
@pool = Pool.find(params[:pool_id])
|
||||
@post = Post.find(params[:post_id])
|
||||
@pool.remove_post!(@post)
|
||||
@pool.remove!(@post)
|
||||
respond_with(@pool, :location => pool_path(@pool))
|
||||
end
|
||||
|
||||
12
app/controllers/pool_orders_controller.rb
Normal file
12
app/controllers/pool_orders_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class PoolOrdersController < ApplicationController
|
||||
respond_to :html, :xml, :json, :js
|
||||
before_filter :member_only
|
||||
|
||||
def edit
|
||||
@pool = Pool.find(params[:pool_id])
|
||||
respond_with(@pool)
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
end
|
||||
@@ -25,7 +25,9 @@ class PoolsController < ApplicationController
|
||||
|
||||
def show
|
||||
@pool = Pool.find(params[:id])
|
||||
@post_set = PostSets::Pool.new(@pool, :page => params[:page])
|
||||
@post_set = PostSets::Base.new(:id => @pool, :page => params[:page])
|
||||
@post_set.extend(PostSets::Numbered)
|
||||
@post_set.extend(PostSets::Pool)
|
||||
respond_with(@pool)
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ class PostsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@post_set = PostSets::Post.new(params[:tags], params)
|
||||
@post_set = PostSets::Base.new(params)
|
||||
extend_post_set(@post_set)
|
||||
respond_with(@post_set)
|
||||
end
|
||||
|
||||
@@ -29,6 +30,24 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
def extend_post_set(post_set)
|
||||
@post_set.extend(PostSets::Post)
|
||||
|
||||
if use_sequential_paginator?
|
||||
@post_set.extend(PostSets::Sequential)
|
||||
else
|
||||
@post_set.extend(PostSets::Numbered)
|
||||
end
|
||||
end
|
||||
|
||||
def use_sequential_paginator?
|
||||
if params[:page].to_i > 1000
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def save_recent_tags
|
||||
if params[:tags] || (params[:post] && params[:post][:tags])
|
||||
tags = Tag.scan_tags(params[:tags] || params[:post][:tags])
|
||||
|
||||
Reference in New Issue
Block a user