2010-05-24 00:18:23 +00:00
|
|
|
module Admin
|
|
|
|
class ContentsController < BaseController
|
|
|
|
|
|
|
|
sections 'contents'
|
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
before_filter :set_content_type
|
2010-07-13 20:01:40 +00:00
|
|
|
|
|
|
|
respond_to :json, :only => :update
|
2010-05-24 00:18:23 +00:00
|
|
|
|
|
|
|
def index
|
2010-06-16 14:43:29 +00:00
|
|
|
@contents = @content_type.list_or_group_contents
|
2010-05-24 00:18:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2010-07-13 00:46:17 +00:00
|
|
|
create! do |success, failure|
|
|
|
|
success.html { redirect_to edit_admin_content_url(@content_type.slug, @content) }
|
2010-05-24 00:18:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
def update
|
|
|
|
update! { edit_admin_content_url(@content_type.slug, @content) }
|
2010-05-24 00:18:23 +00:00
|
|
|
end
|
2010-05-25 00:32:12 +00:00
|
|
|
|
|
|
|
def sort
|
2010-05-26 00:41:10 +00:00
|
|
|
@content_type.sort_contents!(params[:order])
|
2010-05-25 00:32:12 +00:00
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
respond_with(@content_type, :location => admin_contents_url(@content_type.slug))
|
2010-05-25 00:32:12 +00:00
|
|
|
end
|
2010-07-13 00:46:17 +00:00
|
|
|
|
2010-05-24 00:18:23 +00:00
|
|
|
def destroy
|
2010-07-13 00:46:17 +00:00
|
|
|
destroy! { admin_contents_url(@content_type.slug) }
|
2010-05-24 00:18:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def set_content_type
|
2010-07-13 00:46:17 +00:00
|
|
|
@content_type ||= current_site.content_types.where(:slug => params[:slug]).first
|
2010-05-24 00:18:23 +00:00
|
|
|
end
|
2010-07-13 00:46:17 +00:00
|
|
|
|
|
|
|
def begin_of_association_chain
|
|
|
|
set_content_type
|
|
|
|
end
|
2010-05-24 00:18:23 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|