orbit-basic/app/controllers/admin/items_controller.rb

34 lines
787 B
Ruby

class Admin::ItemsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :find_snippets, :only => :index
def index
@items = Item.all( :conditions => { :parent_id => @parent_item.id } )
@items.unshift Item.find_by_name("root") if @parent_item.name == 'root'
end
def up
@item = Item.find(params[:id])
@item.move_higher
redirect_to admin_items_url( :parent_name => @item.parent_name )
end
def down
@item = Item.find(params[:id])
@item.move_lower
redirect_to admin_items_url( :parent_name => @item.parent_name )
end
protected
def find_snippets
@snippets = Snippet.all( :conditions => { :parent_id => @parent_item.id } )
end
end