Sha256: 2687d52df976c1163425db11a1c70e4196c3a40cfca605e315ed1442862a4aaf
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
class Admin::PostsController < Admin::BaseController resource_controller :except => [:show] index.response do |wants| wants.html { render :action => :index } wants.json { render :json => @collection.to_json() } end new_action.response do |wants| wants.html {render :action => :new, :layout => false} end create.before :create_before create.response do |wants| # go to edit form after creating as new post wants.html {redirect_to edit_admin_post_url(Post.find(@post.id)) } end update.response do |wants| # override the default redirect behavior of r_c # need to reload Post in case name / permalink has changed wants.html {redirect_to edit_admin_post_url(Post.find(@post.id)) } end private def collection unless request.xhr? # Note: the SL scopes are on/off switches, so we need to select "not_deleted" explicitly if the switch is off # QUERY - better as named scope or as SL scope? #if params[:search].nil? || params[:search][:deleted_at_not_null].blank? # base_scope = base_scope.not_deleted #end @search = Post.searchlogic(params[:search]) # @search = Post.search(params[:search]) # @search.order ||= "ascend_by_title" @collection = @search.do_search.paginate( :per_page => (Spree::Config[:per_page]||50), :page => params[:page] ) else @collection = Post.title_contains(params[:q]).all(:include => includes, :limit => 10) @collection.uniq! end end # set the default published and comment status if applicable def create_before return unless Spree::Config[:cms_post_status_default] || Spree::Config[:cms_post_comment_default] @post.is_active = Spree::Config[:cms_post_status_default] @post.commentable = Spree::Config[:cms_post_comment_default] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree_cms-0.0.4 | app/controllers/admin/posts_controller.rb |