Sha256: 94846e8c297a318222718cd975b0a0e81ee7b4886ecbf32b0d368ff3ac28b7c1

Contents?: true

Size: 1.28 KB

Versions: 19

Compression:

Stored size: 1.28 KB

Contents

module Pageflow
  module Editor
    class EntryPublicationsController < Pageflow::ApplicationController
      respond_to :json

      before_filter :authenticate_user!

      def create
        entry = Entry.find(params[:entry_id])

        authorize!(:publish, entry)
        verify_edit_lock!(entry)

        @entry_publication = build_entry_publication(entry)
        @entry_publication.save!

        render(action: :check)
      rescue Quota::ExceededError
        render(action: :check, status: :forbidden)
      rescue Entry::PasswordMissingError
        head(:bad_request)
      end

      def check
        entry = Entry.find(params[:entry_id])

        authorize!(:publish, entry)

        @entry_publication = build_entry_publication(entry)
      end

      private

      def build_entry_publication(entry)
        EntryPublication.new(entry,
                             entry_publication_params,
                             published_entries_quota(entry),
                             current_user)
      end

      def entry_publication_params
        params.fetch(:entry_publication, {}).permit(:published_until, :password, :password_protected)
      end

      def published_entries_quota(entry)
        Pageflow.config.quotas.get(:published_entries, entry.account)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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