Sha256: 429b591e3830cdd492f3f750bdc29fec56dc233f438d99f528bbfadd1509e33a

Contents?: true

Size: 1.26 KB

Versions: 68

Compression:

Stored size: 1.26 KB

Contents

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

      before_action :authenticate_user!

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

        authorize!(:confirm_encoding, entry.to_model)
        @encoding_confirmation = build_encoding_confirmation(entry)
        @encoding_confirmation.save!

        render(json: {})
      rescue EncodingConfirmation::QuotaExceededError
        render(action: :check, status: :forbidden)
      end

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

        authorize!(:confirm_encoding, entry.to_model)
        @encoding_confirmation = build_encoding_confirmation(entry)
      end

      private

      def build_encoding_confirmation(entry)
        EncodingConfirmation.new(entry,
                                 encoding_confirmation_params,
                                 encoding_quota(entry),
                                 current_user)
      end

      def encoding_confirmation_params
        params.require(:encoding_confirmation).permit(video_file_ids: [], audio_file_ids: [])
      end

      def encoding_quota(entry)
        Pageflow.config.quotas.get(:encoding, entry.account)
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-17.0.3 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-17.0.2 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-17.0.1 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-17.0.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-16.2.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-16.1.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-16.0.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.8.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-14.5.2 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.7.1 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.7.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.6.1 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.6.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.5.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.4.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.3.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.2.2 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.2.1 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-15.2.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb