Sha256: eb8ec63cd716c5bb78ac2c8b3053ac0fa00c96deb688f2768a80be18a1bbf000

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

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

      before_filter :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!

        head :ok
      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,
                                 current_user)
      end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pageflow-0.3.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-0.2.1 app/controllers/pageflow/editor/encoding_confirmations_controller.rb
pageflow-0.2.0 app/controllers/pageflow/editor/encoding_confirmations_controller.rb