Sha256: 912d73ea89bdf19dda2f171705ed065cbda85f27440ff471b156a030db5e5c7e

Contents?: true

Size: 1019 Bytes

Versions: 10

Compression:

Stored size: 1019 Bytes

Contents

module HelenaAdministration
  class ImportSurveysController < ApplicationController
    before_action :add_breadcrumbs

    def new
      add_breadcrumb t('.import')
      @import_survey_form = ImportSurveyForm.new
    end

    # rubocop:disable Metrics/MethodLength
    def create
      @import_survey_form = ImportSurveyForm.new import_survey_form_params
      if @import_survey_form.valid?
        begin
          Helena::SurveyImporter.new @import_survey_form.script
          flash[:success] = t('shared.actions.created')
          redirect_to surveys_path
        rescue => e
          @error = e

          render 'new'
        end
      else
        flash.now[:danger] = t('shared.actions.error')
        render 'new'
      end
    end
    # rubocop:enable Metrics/MethodLength

    private

    def import_survey_form_params
      params.require(:import_survey_form).permit(:script)
    end

    def add_breadcrumbs
      add_breadcrumb t('shared.navigation.dashboard'), dashboard_index_path
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
helena_administration-0.3.1 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.3.0 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.2.3 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.2.0 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.1.1 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.1.0 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.0.7 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.0.6 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.0.5 app/controllers/helena_administration/import_surveys_controller.rb
helena_administration-0.0.2 app/controllers/helena_administration/import_surveys_controller.rb