Sha256: 1118749c7c8473d47d337bd3485e092824be9eabddc970bd75ddb89cbe32536e
Contents?: true
Size: 1.76 KB
Versions: 16
Compression:
Stored size: 1.76 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, :update] before_filter :load_draft_link, :only => [:edit] 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]) 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
Version data entries
16 entries across 16 versions & 4 rubygems