app/commands/decidim/plans/admin/create_plan.rb in decidim-plans-0.16.9 vs app/commands/decidim/plans/admin/create_plan.rb in decidim-plans-0.17.0

- old
+ new

@@ -32,10 +32,11 @@ Decidim::Plans.tracer.trace!(@form.current_user) do transaction do create_plan create_plan_contents + link_proposals update_attachments if process_attachments? send_notification end end @@ -55,11 +56,10 @@ plan = Plan.new( { published_at: Time.current }.merge(attributes) ) plan.coauthorships.build(author: form.author) plan.save! - plan.proposals << form.proposals plan end @attached_to = @plan end @@ -72,18 +72,28 @@ user: form.current_user ) end end + def link_proposals + plan.link_resources(proposals, "included_proposals") + end + def attributes { title: form.title, category: form.category, scope: form.scope, component: form.component, state: "open", published_at: Time.current } + end + + def proposals + @proposals ||= plan.sibling_scope(:proposals).where( + id: @form.proposal_ids + ) end def send_notification Decidim::EventsManager.publish( event: "decidim.events.plans.plan_published",