This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/items_controller.rb

37 lines
891 B
Ruby

class Admin::ItemsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :find_snippets, :only => :index
before_filter :is_admin?
def index
@items = Item.where(:parent_id => @parent_item.id).entries rescue []
@items = Item.where(:_type => 'Home').entries unless (!@items.empty? || @parent_item)
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