2010-01-14 10:30:53 +00:00
|
|
|
class Admin::ItemsController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
2010-03-04 08:33:26 +00:00
|
|
|
|
|
|
|
before_filter :authenticate_user!
|
2010-01-14 10:30:53 +00:00
|
|
|
before_filter :find_parent_item
|
|
|
|
before_filter :find_snippets, :only => :index
|
2011-04-13 10:19:51 +00:00
|
|
|
before_filter :is_admin?
|
2010-01-14 10:30:53 +00:00
|
|
|
|
|
|
|
def index
|
2011-04-13 10:19:51 +00:00
|
|
|
@items = Item.where(:parent_id => @parent_item.id).entries rescue []
|
|
|
|
@items = Item.where(:_type => 'Home').entries unless (!@items.empty? || @parent_item)
|
2010-02-22 08:10:13 +00:00
|
|
|
end
|
2011-04-13 10:19:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#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
|
2010-02-22 08:10:13 +00:00
|
|
|
|
2010-01-14 10:30:53 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def find_snippets
|
2011-04-13 10:19:51 +00:00
|
|
|
@snippets = Snippet.where( { :parent_id => @parent_item.id } ) rescue nil
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|