Class: Decidim::ActionDelegator::Admin::ManageDelegationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Paginable, NeedsPermission
Defined in:
app/controllers/decidim/action_delegator/admin/manage_delegations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_setting, #organization_settings, #permission_class_chain

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/action_delegator/admin/manage_delegations_controller.rb', line 22

def create
  enforce_permission_to :create, :delegation

  @form = CsvImportForm.from_params(params)

  if @form.valid?
    csv_file = @form.csv_file.download.force_encoding("utf-8").encode("utf-8")
    @import_summary = ImportCsvJob.perform_now("DelegationsCsvImporter", csv_file, current_user, current_setting)
    flash[:notice] = t(".success")
    redirect_to setting_delegations_path(current_setting)
  else
    flash[:alert] = t(".error")
    render :new
  end
end

#newObject



15
16
17
18
19
20
# File 'app/controllers/decidim/action_delegator/admin/manage_delegations_controller.rb', line 15

def new
  enforce_permission_to :create, :delegation

  @form = CsvImportForm.from_params(params)
  @errors = []
end