def move
      @page = Humpyard::Page.find(params[:id])
      
      if @page 
        unless can? :update, @page
          render :json => {
            :status => :failed
          }, :status => 403
          return
        end
        
        parent = Humpyard::Page.find_by_id(params[:parent_id])
        # by default, make it possible to move page to root, uncomment to do otherwise:
        #unless parent
        #  parent = Humpyard::Page.root_page
        #end
        @page.update_attribute :parent, parent
        @prev = Humpyard::Page.find_by_id(params[:prev_id])
        @next = Humpyard::Page.find_by_id(params[:next_id])
        
        do_move(@page, @prev, @next)
        
        replace_options = {
          :element => "hy-page-treeview",
          :content => render_to_string(:partial => "tree.html", :locals => {:page => @page})
        }
        
        render :json => {
          :status => :ok,
          :replace => [replace_options]
        }
      else
        render :json => {
          :status => :failed
        }, :status => 404        
      end
    end
def move
      @page = Humpyard::Page.find(params[:id])
      
      if @page 
        unless can? :update, @page
          render :json => {
            :status => :failed
          }, :status => 403
          return
        end
        
        parent = Humpyard::Page.find_by_id(params[:parent_id])
        # by default, make it possible to move page to root, uncomment to do otherwise:
        #unless parent
        #  parent = Humpyard::Page.root_page
        #end
        @page.update_attribute :parent, parent
        @prev = Humpyard::Page.find_by_id(params[:prev_id])
        @next = Humpyard::Page.find_by_id(params[:next_id])
        
        do_move(@page, @prev, @next)
        
        replace_options = {
          :element => "hy-page-treeview",
          :content => render_to_string(:partial => "tree.html", :locals => {:page => @page})
        }
        
        render :json => {
          :status => :ok,
          :replace => [replace_options]
        }
      else
        render :json => {
          :status => :failed
        }, :status => 404        
      end
    end
Move a page