Sha256: 14c2a4f827739653bddc934b658abae606b853bbc38f17796e9b21bba459f5ae
Contents?: true
Size: 1.17 KB
Versions: 10
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require "csv" module Decidim module Admin class ProcessParticipatorySpacePrivateUserImportCsv < Decidim::Command include Decidim::Admin::CustomImport delegate :current_user, to: :form # Public: Initializes the command. # # form - the form object containing the uploaded file # private_users_to - The private_users_to that will hold the user role def initialize(form, private_users_to) @form = form @private_users_to = private_users_to end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form was not valid and we could not proceed. # # Returns nothing. def call return broadcast(:invalid) unless @form.valid? process_csv broadcast(:ok) end private attr_reader :form def process_csv process_import_file(@form.file) do |(email, user_name)| ImportParticipatorySpacePrivateUserCsvJob.perform_later(email, user_name, @private_users_to, current_user) if email.present? && user_name.present? end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems