Class: Decidim::Accountability::Admin::ImportResultsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/accountability/admin/import_results_controller.rb

Overview

This controller allows an admin to import results from a csv file for the Accountability component

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/decidim/accountability/admin/import_results_controller.rb', line 14

def create
  @form = form(Admin::ImportResultsForm).from_params(params, current_component:)

  if @form.valid?
    Decidim::Accountability::Admin::ImportResultsCsvJob.perform_later(current_user, current_component, @form.local_file_path)

    flash[:notice] = I18n.t("imports.create.success", scope: "decidim.accountability.admin")
    redirect_to import_results_path(current_participatory_space, current_component)
  else
    flash[:alert] = I18n.t("imports.create.invalid", scope: "decidim.accountability.admin")
    render action: "new"
  end
end

#newObject



10
11
12
# File 'app/controllers/decidim/accountability/admin/import_results_controller.rb', line 10

def new
  @form = form(Admin::ImportResultsForm).instance
end