2012-01-24 20:33:34 +00:00
|
|
|
module Locomotive
|
|
|
|
module Api
|
|
|
|
class ContentEntriesController < BaseController
|
|
|
|
|
|
|
|
before_filter :set_content_type
|
|
|
|
|
|
|
|
def index
|
2012-03-07 01:56:56 +00:00
|
|
|
@content_entries = @content_type.ordered_entries
|
2012-01-24 20:33:34 +00:00
|
|
|
respond_with @content_entries
|
|
|
|
end
|
|
|
|
|
2012-03-07 00:39:24 +00:00
|
|
|
def show
|
|
|
|
@content_entry = @content_type.entries.any_of({ :_id => params[:id] }, { :_slug => params[:id] }).first
|
|
|
|
respond_with @content_entry, :status => @content_entry ? :ok : :not_found
|
|
|
|
end
|
|
|
|
|
2012-01-24 20:33:34 +00:00
|
|
|
def create
|
|
|
|
@content_entry = @content_type.entries.create(params[:content_entry])
|
2012-01-26 15:51:32 +00:00
|
|
|
respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
|
2012-01-24 20:33:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@content_entry = @content_type.entries.find(params[:id])
|
|
|
|
@content_entry.update_attributes(params[:content_entry])
|
2012-01-26 15:51:32 +00:00
|
|
|
respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
|
2012-01-24 20:33:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@content_entry = @content_type.entries.find(params[:id])
|
|
|
|
@content_entry.destroy
|
2012-01-26 15:51:32 +00:00
|
|
|
respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
|
2012-01-24 20:33:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def set_content_type
|
|
|
|
@content_type ||= current_site.content_types.where(:slug => params[:slug]).first
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|