Class: Decidim::ActionDelegator::Admin::ManageParticipantsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain

Instance Method Details

#createObject



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

def create
  enforce_permission_to :create, :participant

  @csv_file = params[:csv_file]
  redirect_to seting_manage_participants_path && return if @csv_file.blank?

  csv_file = @csv_file.read.force_encoding("utf-8").encode("utf-8")
  @import_summary = Decidim::ActionDelegator::Admin::ImportCsvJob.perform_later("ParticipantsCsvImporter", csv_file, current_user, current_setting)

  flash[:notice] = t(".success")

  redirect_to decidim_admin_action_delegator.setting_participants_path(current_setting)
end

#destroy_allObject



35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/decidim/action_delegator/admin/manage_participants_controller.rb', line 35

def destroy_all
  enforce_permission_to :destroy, :participant, { resource: current_setting }

  participants_to_remove = current_setting.participants.reject(&:voted?)

  participants_to_remove.each(&:destroy)

  flash[:notice] = I18n.t("participants.remove_census.success", scope: "decidim.action_delegator.admin", participants_count: participants_to_remove.count)
  redirect_to setting_participants_path(current_setting)
end

#newObject



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

def new
  enforce_permission_to :create, :participant

  @errors = []
end