Sha256: 515c1392cdeaf860b23b578206151bdc93914a2f2ee24446502e23c6a5c9f16e

Contents?: true

Size: 844 Bytes

Versions: 3

Compression:

Stored size: 844 Bytes

Contents

module Workarea
  module Admin
    class ImportReviewsController < Admin::ApplicationController
      required_permissions :marketing

      def new
        @import = Import::Review.new
      end

      def create
        @import = Import::Review.new(import_params)

        if @import.save
          ProcessImport.perform_async(@import.to_global_id)

          flash[:success] = t('workarea.admin.import_reviews.flash_messages.processing')
          redirect_to reviews_path
        else
          render :new, status: :unprocessable_entity
        end
      end

      def sample
        send_file Reviews::Engine.root.join('public/workarea/import_samples/reviews.csv')
      end

      private

      def import_params
        params.fetch(:import_review, {})
              .merge(created_by_id: current_user.id)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-reviews-3.0.10 app/controllers/workarea/admin/import_reviews_controller.rb
workarea-reviews-3.0.9 app/controllers/workarea/admin/import_reviews_controller.rb
workarea-reviews-3.0.8 app/controllers/workarea/admin/import_reviews_controller.rb