aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/refinery
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-09-02 16:01:58 -0700
committerJamie Winsor <jamie@enmasse.com>2011-09-03 21:55:30 -0700
commit6212e60f9e4d144f9a136f6c82b33abd47ddb237 (patch)
tree3ba02acc7861ef51045f0196dff6bac9efda40d5 /app/controllers/refinery
parent80ca7c1bf99befac70803309e542a4db54f1f198 (diff)
downloadrefinerycms-blog-6212e60f9e4d144f9a136f6c82b33abd47ddb237.tar.gz
refinerycms-blog-6212e60f9e4d144f9a136f6c82b33abd47ddb237.tar.bz2
refinerycms-blog-6212e60f9e4d144f9a136f6c82b33abd47ddb237.zip
index action of blog post controller now caches and sweeps on changes
fix various views which were broken and untested with rails-3-1 upgrade add request spec tests for admin blog comments Factory is now FactoryGirl Fix multiple issues around listing unmoderated comments use cleaner definitions to set per_page willpaginate attribute on models update all paginate calls to use new arel representation reorganize filter sections to be located at top of controller modify uncategorized class method to activerecord scope and perform a left outer join instead of iterate through an array to find uncategorized posts move request specs into their proper places update guardfile to ensure that request specs get run when their respective controllers are modified Fix show action for AdminBlogComments and added test Fix redirection link after approving or rejecting a comment
Diffstat (limited to 'app/controllers/refinery')
-rw-r--r--app/controllers/refinery/admin/blog/comments_controller.rb21
-rw-r--r--app/controllers/refinery/admin/blog/posts_controller.rb20
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb7
3 files changed, 28 insertions, 20 deletions
diff --git a/app/controllers/refinery/admin/blog/comments_controller.rb b/app/controllers/refinery/admin/blog/comments_controller.rb
index 9f78caa..f14e8eb 100644
--- a/app/controllers/refinery/admin/blog/comments_controller.rb
+++ b/app/controllers/refinery/admin/blog/comments_controller.rb
@@ -2,37 +2,44 @@ module Refinery
module Admin
module Blog
class CommentsController < ::Admin::BaseController
+
+ cache_sweeper Refinery::BlogSweeper
crudify :'refinery/blog_comment',
:title_attribute => :name,
:order => 'published_at DESC'
def index
- @blog_comments = Refinery::BlogComment.unmoderated
+ @blog_comments = Refinery::BlogComment.unmoderated.page(params[:page])
+
render :action => 'index'
end
def approved
unless params[:id].present?
- @blog_comments = Refinery::BlogComment.approved
+ @blog_comments = Refinery::BlogComment.approved.page(params[:page])
+
render :action => 'index'
else
@blog_comment = Refinery::BlogComment.find(params[:id])
@blog_comment.approve!
- flash[:notice] = t('approved', :scope => 'admin.blog.comments', :author => @blog_comment.name)
- redirect_to :action => params[:return_to] || 'index'
+ flash[:notice] = t('approved', :scope => 'refinery.admin.blog.comments', :author => @blog_comment.name)
+
+ redirect_to main_app.url_for(:action => params[:return_to] || 'index')
end
end
def rejected
unless params[:id].present?
- @blog_comments = Refinery::BlogComment.rejected
+ @blog_comments = Refinery::BlogComment.rejected.page(params[:page])
+
render :action => 'index'
else
@blog_comment = Refinery::BlogComment.find(params[:id])
@blog_comment.reject!
- flash[:notice] = t('rejected', :scope => 'admin.blog.comments', :author => @blog_comment.name)
- redirect_to :action => params[:return_to] || 'index'
+ flash[:notice] = t('rejected', :scope => 'refinery.admin.blog.comments', :author => @blog_comment.name)
+
+ redirect_to main_app.url_for(:action => params[:return_to] || 'index')
end
end
diff --git a/app/controllers/refinery/admin/blog/posts_controller.rb b/app/controllers/refinery/admin/blog/posts_controller.rb
index 548f8c9..17ebe87 100644
--- a/app/controllers/refinery/admin/blog/posts_controller.rb
+++ b/app/controllers/refinery/admin/blog/posts_controller.rb
@@ -1,18 +1,21 @@
-require 'will_paginate/array'
-
module Refinery
module Admin
module Blog
class PostsController < ::Admin::BaseController
-
+
+ cache_sweeper Refinery::BlogSweeper
crudify :'refinery/blog_post',
:title_attribute => :title,
:order => 'published_at DESC'
+
+ before_filter :find_all_categories,
+ :only => [:new, :edit, :create, :update]
+
+ before_filter :check_category_ids, :only => :update
def uncategorized
- @blog_posts = Refinery::BlogPost.uncategorized.paginate(:page => params[:page],
- :per_page => Refinery::BlogPost.per_page)
+ @blog_posts = Refinery::BlogPost.uncategorized.page(params[:page])
end
def tags
@@ -71,7 +74,7 @@ module Refinery
unless request.xhr?
render :action => 'new'
else
- render :partial => "/shared/admin/error_messages",
+ render :partial => "/refinery/admin/error_messages",
:locals => {
:object => @blog_post,
:include_object_name => true
@@ -80,11 +83,6 @@ module Refinery
end
end
- before_filter :find_all_categories,
- :only => [:new, :edit, :create, :update]
-
- before_filter :check_category_ids, :only => :update
-
protected
def find_all_categories
@blog_categories = Refinery::BlogCategory.find(:all)
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb
index 167aef3..aa7d45e 100644
--- a/app/controllers/refinery/blog/posts_controller.rb
+++ b/app/controllers/refinery/blog/posts_controller.rb
@@ -1,6 +1,9 @@
module Refinery
module Blog
class PostsController < BlogController
+
+ caches_page :index
+ # cache_sweeper Refinery::BlogSweeper, :only => [:comment]
before_filter :find_all_blog_posts, :except => [:archive]
before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
@@ -38,10 +41,10 @@ module Refinery
if Refinery::BlogComment::Moderation.enabled?
flash[:notice] = t('thank_you_moderated', :scope => 'blog.posts.comments')
- redirect_to blog_post_url(params[:id])
+ redirect_to main_app.blog_post_url(params[:id])
else
flash[:notice] = t('thank_you', :scope => 'blog.posts.comments')
- redirect_to blog_post_url(params[:id],
+ redirect_to main_app.blog_post_url(params[:id],
:anchor => "comment-#{@blog_comment.to_param}")
end
else