Sha256: 4b4ffd895712c955be574896c1e4fccbbe9fa334e5f1433405bffb881a229fa9

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

module Locomotive
  module Api
    class ContentEntriesController < BaseController

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

      def index
        @content_entries = @content_entries.order_by([get_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 get_content_type
        @content_type ||= current_site.content_types.where(slug: params[:slug]).first
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
locomotive_cms-2.5.4 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.3 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.2 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.1 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.0 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.0.rc3 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.0.rc2 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.5.0.rc1 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.4.1 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.4.0 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.3.1 app/controllers/locomotive/api/content_entries_controller.rb
locomotive_cms-2.3.0 app/controllers/locomotive/api/content_entries_controller.rb