Sha256: ae521ccf661a6ce587b02aec88d4d070b1c1d21271a431a9fe6f6fbf1bcc15c0

Contents?: true

Size: 1.65 KB

Versions: 25

Compression:

Stored size: 1.65 KB

Contents

module Pageflow
  class StorylinesController < Pageflow::ApplicationController
    respond_to :json

    before_filter :authenticate_user!

    def create
      entry = DraftEntry.find(params[:entry_id])
      storyline = entry.storylines.build(storyline_params)

      authorize!(:create, storyline)
      verify_edit_lock!(entry.to_model)
      storyline.save

      respond_with(storyline)
    end

    def scaffold
      entry = DraftEntry.find(params[:entry_id])
      storyline_scaffold = StorylineScaffold.build(entry, storyline_params, params.slice(:depth))

      authorize!(:create, storyline_scaffold.to_model)
      verify_edit_lock!(entry.to_model)
      storyline_scaffold.save!

      respond_with(storyline_scaffold)
    end

    def update
      storyline = Storyline.find(params[:id])

      authorize!(:update, storyline)
      verify_edit_lock!(storyline.entry)
      storyline.update_attributes(storyline_params)

      respond_with(storyline)
    end

    def order
      entry = DraftEntry.find(params[:entry_id])

      authorize!(:edit_outline, entry.to_model)
      verify_edit_lock!(entry)
      params.require(:ids).each_with_index do |id, index|
        entry.storylines.update(id, position: index)
      end

      head :no_content
    end

    def destroy
      storyline = Storyline.find(params[:id])

      authorize!(:destroy, storyline)
      verify_edit_lock!(storyline.entry)

      storyline.destroy

      respond_with(storyline)
    end

    private

    def storyline_params
      configuration = params.require(:storyline)[:configuration].try(:permit!)
      params.require(:storyline).permit.merge(configuration: configuration)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
pageflow-12.6.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.5.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.4.1 app/controllers/pageflow/storylines_controller.rb
pageflow-12.4.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.3.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.2.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.1.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.4 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.3 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.2 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.1 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc7 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc6 app/controllers/pageflow/storylines_controller.rb
pageflow-0.11.4 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc5 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc4 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc3 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc2 app/controllers/pageflow/storylines_controller.rb
pageflow-12.0.0.rc1 app/controllers/pageflow/storylines_controller.rb