9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/jobs/decidim/proposals/admin/import_proposals_job.rb', line 9
def perform(form)
@form = form
ActiveRecord::Base.transaction do
proposals.map do |original_proposal|
next if proposal_already_copied?(original_proposal, target_component)
Decidim::Proposals::ProposalBuilder.copy(
original_proposal,
author: proposal_author,
action_user: current_user,
extra_attributes: {
"component" => target_component
}.merge(proposal_answer_attributes(original_proposal))
)
end
end
ImportProposalsMailer.notify_success(current_user, origin_component, target_component, proposals.count).deliver_later
rescue ActiveRecord::RecordNotFound, NoMethodError
ImportProposalsMailer.notify_failure(current_user, origin_component, target_component).deliver_later
end
|