2010-01-14 10:30:53 +00:00
|
|
|
class Admin::ItemsController < ApplicationController
|
|
|
|
|
2011-05-09 10:49:57 +00:00
|
|
|
layout "content"
|
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?
|
2011-05-13 01:08:42 +00:00
|
|
|
before_filter :set_current_item
|
2010-01-14 10:30:53 +00:00
|
|
|
|
|
|
|
def index
|
2011-05-09 10:49:57 +00:00
|
|
|
if params[:item_id]
|
2011-05-13 01:08:42 +00:00
|
|
|
@item = Item.find(params[:item_id])
|
2011-05-09 10:49:57 +00:00
|
|
|
else
|
2011-09-01 01:12:41 +00:00
|
|
|
@item = get_homepage
|
2011-05-09 10:49:57 +00:00
|
|
|
end
|
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
|