Sha256: 9cb896bf24735b6c7511125ff8f25d9d574ce5fcd62cc468158361a83ae02c26

Contents?: true

Size: 1.32 KB

Versions: 19

Compression:

Stored size: 1.32 KB

Contents

class Pulitzer::VersionsController < Pulitzer::ApplicationController
  before_action :set_version

  def edit
    render_ajax locals: { version: @version }
  end

  def update
    status_updater = Pulitzer::UpdateVersionStatus.new(@version, @status)
    if status_updater.errors.any?
      processing_version  = @version
      flash_message       = status_updater.errors.join("<br>").html_safe
      status = :conflict
    else
      processing_version  = status_updater.call
      if processing_version
        if processing_version.errors.empty?
          status = :ok
          flash_message     = "The new version of #{@post.title} has been activated."
        else
          status = :conflict
          flash_message = processing_version.errors.full_messages.join("<br>").html_safe
        end
      else
        flash[:notice] = "The post was successfully removed."
        render json: {class_triggers: {"hooch.ReloadPage" => posts_path(post_type_id: @version.post.post_type.id) }} and return
      end
    end
    render json: {html: render_to_string(partial: '/pulitzer/versions/edit', locals: {version: processing_version}),
                  flash_message: flash_message}, status: status
  end

private
  def set_version
    @version  = Pulitzer::Version.find params[:id]
    @status = params[:status]
    @post = @version.post
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pulitzer-0.15.31 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.30 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.29 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.28 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.27 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.26 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.25 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.24 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.23 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.22 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.21 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.20 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.19 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.18 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.17 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.16 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.15 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.14 app/controllers/pulitzer/versions_controller.rb
pulitzer-0.15.13 app/controllers/pulitzer/versions_controller.rb