Sha256: 69739a67d59c52121e7e150606e167edd6fde7a1a0b1e7cc9c6d246beebb5d96

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

module Locomotive
  module Api
    class ContentEntriesController < BaseController

      load_and_authorize_resource({
        class:                Locomotive::ContentEntry,
        through:              :content_type,
        through_association:  :entries,
        find_by:              :find_by_id_or_permalink
      })

      def index
        @content_entries = @content_entries.order_by([content_type.order_by_definition])
        respond_with @content_entries
      end

      def show
        respond_with @content_entry, status: @content_entry ? :ok : :not_found
      end

      def create
        @content_entry.from_presenter(params[:content_entry] || params[:entry])
        @content_entry.save
        respond_with @content_entry, location: main_app.locomotive_api_content_entries_url(@content_type.slug)
      end

      def update
        @content_entry.from_presenter(params[:content_entry] || params[:entry])
        @content_entry.save
        respond_with @content_entry, location: main_app.locomotive_api_content_entries_url(@content_type.slug)
      end

      def destroy
        @content_entry.destroy
        respond_with @content_entry, location: main_app.locomotive_api_content_entries_url(@content_type.slug)
      end

      protected

      def content_type
        @content_type ||= current_site.content_types.where(slug: params[:slug]).first
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
locomotive_cms-2.2.3 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.2.2 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.2.1 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.2.0 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.1.4 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.1.3 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.1.2 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.1.1 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.1.0 app/controllers/locomotive/api/content_entries_controller.rb