app/commands/decidim/proposals/admin/import_proposals.rb in decidim-proposals-0.14.4 vs app/commands/decidim/proposals/admin/import_proposals.rb in decidim-proposals-0.15.0

- old
+ new

@@ -31,31 +31,17 @@ def import_proposals proposals.map do |original_proposal| next if proposal_already_copied?(original_proposal, target_component) - origin_attributes = original_proposal.attributes.except( - "id", - "created_at", - "updated_at", - "state", - "answer", - "answered_at", - "decidim_component_id", - "reference", - "proposal_votes_count", - "proposal_notes_count" + Decidim::Proposals::ProposalBuilder.copy( + original_proposal, + author: form.current_organization, + action_user: form.current_user, + extra_attributes: { + "component" => target_component + } ) - - proposal = Decidim::Proposals::Proposal.new(origin_attributes) - proposal.category = original_proposal.category - proposal.component = target_component - proposal.save! - - proposal.link_resources([original_proposal], "copied_from_component") - original_proposal.coauthorships.each do |coauthorship| - Decidim::Coauthorship.create(author: coauthorship.author, user_group: coauthorship.user_group, coauthorable: proposal) - end end.compact end def proposals Decidim::Proposals::Proposal