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

41 lines
906 B
Ruby
Raw Normal View History

class Admin::ItemsController < ApplicationController
layout "content"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :find_snippets, :only => :index
before_filter :is_admin?
2011-05-13 01:08:42 +00:00
before_filter :set_current_item
def index
if params[:item_id]
2011-05-13 01:08:42 +00:00
@item = Item.find(params[:item_id])
else
2011-05-13 01:08:42 +00:00
@item = Item.first(:conditions => {:parent_id => nil})
end
end
#TODO
# Allow to move items down and up different parents
# 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.where( { :parent_id => @parent_item.id } ) rescue nil
end
end