2010-06-10 13:30:32 +00:00
|
|
|
module Admin
|
|
|
|
class ApiContentsController < ActionController::Base
|
|
|
|
|
|
|
|
include Locomotive::Routing::SiteDispatcher
|
|
|
|
|
|
|
|
before_filter :require_site
|
|
|
|
|
|
|
|
before_filter :set_content_type
|
|
|
|
|
|
|
|
def create
|
|
|
|
@content = @content_type.contents.build(params[:content])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @content.save
|
|
|
|
format.json { render :json => { :content => @content } }
|
|
|
|
else
|
|
|
|
format.json { render :json => { :content => @content, :errors => @content.errors } }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def set_content_type
|
2010-06-10 14:50:50 +00:00
|
|
|
@content_type = current_site.content_types.where(:slug => params[:slug]).first
|
|
|
|
render :json => { :error => 'Api not enabled'} and return false unless @content_type.api_enabled
|
2010-06-10 13:30:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|