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

Inherits:
ApplicationController show all
Defined in:
decidim-accountability/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

Methods inherited from Decidim::Admin::Components::BaseController

#current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #skip_manage_component_permission

Methods included from RegistersPermissions

register_permissions

Methods inherited from Decidim::Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


12
13
14
15
16
17
18
19
20
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/import_results_controller.rb', line 12

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

#newObject


8
9
10
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/import_results_controller.rb', line 8

def new
  @errors = []
end