Sha256: 3689a095cfe385de0148c064eb50d172698fdd6b64b153483e8c90c4eb09b62c

Contents?: true

Size: 1.84 KB

Versions: 17

Compression:

Stored size: 1.84 KB

Contents

module Locomotive
  class ContentEntriesController < BaseController

    sections 'contents'

    localized

    before_filter :back_to_default_site_locale, :only => %w(new create)

    before_filter :set_content_type

    respond_to :json, :only => [:show, :edit, :create, :update, :sort]

    skip_load_and_authorize_resource

    before_filter :authorize_content

    def index
      @content_entries = @content_type.list_or_group_entries
      respond_with @content_entries
    end

    def show
      @content_entry = @content_type.entries.find(params[:id])
      respond_with @content_entry
    end

    def new
      @content_entry = @content_type.entries.build
      respond_with @content_entry
    end

    def create
      @content_entry = @content_type.entries.create(params[:content_entry])
      respond_with @content_entry, :location => edit_content_entry_url(@content_type.slug, @content_entry._id)
    end

    def edit
      @content_entry = @content_type.entries.find(params[:id])
      respond_with @content_entry
    end

    def update
      @content_entry = @content_type.entries.find(params[:id])
      @content_entry.update_attributes(params[:content_entry])
      respond_with @content_entry, :location => edit_content_entry_url(@content_type.slug, @content_entry._id)
    end

    def sort
      @content_type.klass_with_custom_fields(:entries).sort_entries!(params[:entries])
      respond_with @content_type
    end

    def destroy
      @content_entry = @content_type.entries.find(params[:id])
      @content_entry.destroy
      respond_with @content_entry, :location => content_entries_url(@content_type.slug)
    end

    protected

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

    def authorize_content
      authorize! params[:action].to_sym, ContentEntry
    end

  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
locomotive_cms-2.0.3 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.2 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.1 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0 app/controllers/locomotive/content_entries_controller.rb
tribeca_cms-0.1.1 app/controllers/locomotive/content_entries_controller.rb
tribeca_cms-2.0.0.rc12 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc12 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc11 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc10 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc9 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc8 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc7 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc6 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc5 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc4 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc2 app/controllers/locomotive/content_entries_controller.rb
locomotive_cms-2.0.0.rc1 app/controllers/locomotive/content_entries_controller.rb