Sha256: e99847d6c5176d94b1b6145c16fad2852bf27ba2894816374117cdd102bf544b

Contents?: true

Size: 1.61 KB

Versions: 8

Compression:

Stored size: 1.61 KB

Contents

class Cms::LinksController < Cms::BaseController

  before_filter :set_toolbar_tab
  before_filter :load_section, :only => [:new, :create, :move_to]
  before_filter :load_link, :only => [:destroy]
  before_filter :load_draft_link, :only => [:edit, :update]
  
  def new
    @link = Link.new(:section => @section)
  end

  def create
    @link = Link.new(params[:link])
    @link.section = @section
    if @link.save
      flash[:notice] = "Link was '#{@link.name}' created."
      redirect_to [:cms, @section]
    else
      render :action => "new"
    end
  end
  
  def update
    if @link.update_attributes(params[:link])
      flash[:notice] = "Link '#{@link.name}' was updated"
      redirect_to [:cms, @link.section]
    else
      render :action => 'edit'
    end      
  end
  
  def destroy
    respond_to do |format|
      if @link.destroy
        message = "Link '#{@link.name}' was deleted."
        format.html { flash[:notice] = message; redirect_to(cms_sitemap_url) }
        format.json { render :json => {:success => true, :message => message } }
      else
        message = "Link '#{@link.name}' could not be deleted"
        format.html { flash[:error] = message; redirect_to(cms_sitemap_url) }
        format.json { render :json => {:success => false, :message => message } }
      end
    end    
  end

  protected

    def load_section
      @section = Section.find(params[:section_id])
    end

    def load_link
      @link = Link.find(params[:id])
    end
    
    def load_draft_link
      load_link
      @link = @link.as_of_draft_version
    end

    def set_toolbar_tab
      @toolbar_tab = :sitemap
    end

end

Version data entries

8 entries across 8 versions & 5 rubygems

Version Path
SFEley-browsercms-3.0.2 app/controllers/cms/links_controller.rb
buzzware-browsercms-3.0.2 app/controllers/cms/links_controller.rb
coredumplings-browsercms-3.0.0 app/controllers/cms/links_controller.rb
we5-browsercms-3.0.1.1 app/controllers/cms/links_controller.rb
we5-browsercms-3.0.2 app/controllers/cms/links_controller.rb
browsercms-3.0.2 app/controllers/cms/links_controller.rb
browsercms-3.0.1 app/controllers/cms/links_controller.rb
browsercms-3.0.0 app/controllers/cms/links_controller.rb