Class: Decidim::Admin::ImportParticipatorySpacePrivateUserCsvJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
decidim-admin/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb

Overview

Custom ApplicationJob scoped to the admin panel.

Instance Method Summary collapse

Instance Method Details

#perform(email, user_name, privatable_to, current_user) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'decidim-admin/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb', line 10

def perform(email, user_name, privatable_to, current_user)
  return if email.blank? || user_name.blank?

  params = {
    name: user_name,
    email: email.downcase.strip
  }
  private_user_form = ParticipatorySpacePrivateUserForm.from_params(params, privatable_to: privatable_to)
                                                       .with_context(
                                                         current_user: current_user,
                                                         current_particiaptory_space: privatable_to
                                                       )

  Decidim::Admin::CreateParticipatorySpacePrivateUser.call(private_user_form, current_user, privatable_to, via_csv: true)
end