Sha256: 9afbfe1b0b3610996997f56f8937cd96598a2c32e6e369649cbd344f911f91ee
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
# frozen_string_literal: true module Decidim module ActionDelegator module Admin class ManageParticipantsController < ActionDelegator::Admin::ApplicationController include NeedsPermission include Decidim::Paginable helper ::Decidim::ActionDelegator::Admin::DelegationHelper helper_method :organization_settings, :current_setting layout "decidim/admin/users" def new enforce_permission_to :create, :participant @errors = [] end def create enforce_permission_to :create, :participant @csv_file = params[:csv_file] redirect_to seting_manage_participants_path && return if @csv_file.blank? importer_type = "ParticipantsCsvImporter" csv_file = @csv_file.read.force_encoding("utf-8").encode("utf-8") @import_summary = Decidim::ActionDelegator::Admin::ImportCsvJob.perform_later(importer_type, csv_file, current_user, current_setting) flash[:notice] = t(".success") redirect_to decidim_admin_action_delegator.setting_participants_path(current_setting) end 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 private def current_setting @current_setting ||= organization_settings.find_by(id: params[:setting_id]) end def organization_settings Decidim::ActionDelegator::OrganizationSettings.new(current_organization).query end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems