Sha256: bbcc063374fea213993d231af0ef282de55dbe5f6f9a337905d1f5ca9a720ebc
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
module Cms class LinksController < Cms::BaseController before_filter :set_toolbar_tab before_filter :load_section, :only => [:new, :create, :move_to] before_filter :load_link, :only => [:destroy, :update] before_filter :load_draft_link, :only => [:edit] def new @link = Link.new(:section => @section) end def create @link = Link.new(params[:cms_link]) @link.section = @section if @link.save flash[:notice] = "Link was '#{@link.name}' created." redirect_to @section else render :action => "new" end end def update if @link.update_attributes(params[:cms_link]) flash[:notice] = "Link '#{@link.name}' was updated" redirect_to @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(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(sitemap_url) } format.json { render :json => {:success => false, :message => message } } end end end protected def load_section @section = Section.find(params[:section_id]) raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) end def load_link @link = Link.find(params[:id]) raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@link) end def load_draft_link load_link @link = @link.as_of_draft_version end def set_toolbar_tab @toolbar_tab = :sitemap end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
browsercms-3.4.0.rc2 | app/controllers/cms/links_controller.rb |
browsercms-3.4.0.rc1 | app/controllers/cms/links_controller.rb |