Class: Decidim::Votings::Census::Admin::CreateDatumJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
decidim-elections/app/jobs/decidim/votings/census/admin/create_datum_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(user, dataset, csv_row) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-elections/app/jobs/decidim/votings/census/admin/create_datum_job.rb', line 10

def perform(user, dataset, csv_row)
  return if user.blank? || dataset.blank? || csv_row.blank?

  params = {
    document_number: csv_row[0],
    document_type: csv_row[1],
    birthdate: csv_row[2],
    full_name: csv_row[3],
    full_address: csv_row[4],
    postal_code: csv_row[5],
    mobile_phone_number: csv_row[6],
    email: csv_row[7],
    ballot_style_code: csv_row[8]
  }

  datum_form = DatumForm.from_params(params)
                        .with_context(
                          current_user: user,
                          dataset: dataset
                        )

  CreateDatum.call(datum_form, dataset)
end