Skip to content

Commit

Permalink
Adding spree 1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Cruz committed Feb 4, 2012
1 parent 9a8ae70 commit 76f3ede
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions app/controllers/admin/reviews_controller.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
class Admin::ReviewsController < Spree::Admin::BaseController
class Admin::ReviewsController < Spree::Admin::ResourceController
#require_role "admin" # You might want to remove this, and add security in the /config/easy_role_permissions.yml file
layout 'admin'

resource_controller
before_filter :index_before, :only => [:index]

index.before do
@unapproved_reviews = Review.not_approved.find(:all, :order => "created_at DESC")
@approved_reviews = Review.approved.find(:all, :order => "created_at DESC")
end

create.response do |wants|
wants.html { redirect_to admin_reviews_path }
end

update.response do |wants|
wants.html { redirect_to admin_reviews_path }
end
#create.response do |wants|
# wants.html { redirect_to admin_reviews_path }
#end
#
#update.response do |wants|
# wants.html { redirect_to admin_reviews_path }
#end

def approve
r = Review.find(params[:id])
Expand All @@ -34,4 +29,9 @@ def approve
redirect_to admin_reviews_path
end

protected
def index_before
@unapproved_reviews = Review.not_approved.find(:all, :order => "created_at DESC")
@approved_reviews = Review.approved.find(:all, :order => "created_at DESC")
end
end
2 changes: 1 addition & 1 deletion app/models/review.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class Review < ActiveRecord::Base
scope :approval_filter, lambda {|*args| {:conditions => ["(? = 't') || (approved = 't')", Spree::Reviews::Config[:include_unapproved_reviews]]}}

scope :oldest_first, :order => "created_at asc"
scope :preview, :limit => Spree::Reviews::Config[:preview_size], :order=>"created_at desc"
scope :preview, :limit => Spree::Reviews::Config.preview_size, :order=>"created_at desc"

end

0 comments on commit 76f3ede

Please sign in to comment.