Sha256: 4011610b65e46f660e6db070f076acde1e3b8c544281c5b0b6a5bb0cce3d077c
Contents?: true
Size: 1.89 KB
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-action_delegator-0.8.1 | app/controllers/decidim/action_delegator/admin/manage_participants_controller.rb |