Sha256: b3bb8e7979240bd0f2a404bfb8d84ba39ab1cd964461b7ef21a6020fcbe76873
Contents?: true
Size: 1.59 KB
Versions: 4
Compression:
Stored size: 1.59 KB
Contents
module CopyMove module Controller def self.included(base) base.class_eval do before_filter do |c| c.include_stylesheet 'admin/copy_move' end before_filter :load_page, :only => [:copy_page, :copy_children, :copy_tree, :move] before_filter :load_parent, :only => [:copy_page, :copy_children, :copy_tree, :move] end end def copy_page @new_page = @page.copy_to(@parent, params[:status_id]) flash[:notice] = I18n.t('copied', :scope => :copy_move, :page => @page.title, :parent => @parent.title) redirect_to admin_pages_url end def copy_children @new_page = @page.copy_with_children_to(@parent, params[:status_id]) flash[:notice] = I18n.t('immediate_children_copied', :scope => :copy_move, :page => @page.title, :parent => @parent.title) redirect_to admin_pages_url end def copy_tree @new_page = @page.copy_tree_to(@parent, params[:status_id]) flash[:notice] = I18n.t('descendants_copied', :scope => :copy_move, :page => @page.title, :parent => @parent.title) redirect_to admin_pages_url end def move @page.move_under(@parent) flash[:notice] = I18n.t('descendants_moved', :scope => :copy_move, :page => @page.title, :parent => @parent.title) redirect_to admin_pages_url rescue CopyMove::CircularHierarchy => e flash[:error] = e.message redirect_to admin_pages_url end private def load_parent @parent = Page.find(params[:parent_id]) end def load_page self.model = @page = Page.find(params[:id]) end end end
Version data entries
4 entries across 4 versions & 1 rubygems