Sha256: 0c5eb6bc9dbc04ca09b7a23a598dd797061d61cae276eb8b781c979f5cc122b4

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    module Admin
      # This controller allows an admin to import results from a csv file for the Accountability component
      class ImportResultsController < Admin::ApplicationController
        def new
          @errors = []
        end

        def create
          @csv_file = params[:csv_file]
          redirect_to(new_import_path) && return if @csv_file.blank?

          Decidim::Accountability::Admin::ImportResultsCSVJob.perform_later(current_user, current_component, @csv_file.read.force_encoding("utf-8").encode("utf-8"))

          flash[:notice] = I18n.t("imports.create.success", scope: "decidim.accountability.admin")
          redirect_to import_results_path(current_participatory_process, current_component)
        end

        private

        def current_component
          @current_component ||= current_participatory_process.components.find(params[:component_id])
        end

        def current_participatory_process
          @current_participatory_process ||= ParticipatoryProcess.find_by(slug: params[:participatory_process_slug])
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
decidim-accountability-0.24.3 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.6 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.24.2 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.5 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.24.1 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.24.0 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.24.0.rc2 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.4 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.24.0.rc1 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.3 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.2 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.1 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.1.rc1 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.23.0 app/controllers/decidim/accountability/admin/import_results_controller.rb
decidim-accountability-0.22.0 app/controllers/decidim/accountability/admin/import_results_controller.rb