Sha256: 944fa88f76946cae1f08d0fd0ac51c0492f2ea4a86075324cb806afb9eb174cf
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Decidim module Budgets module Admin # This command is executed when the user creates a Project from the admin # panel. class CreateProject < Rectify::Command def initialize(form) @form = form end # Creates the project if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if @form.invalid? transaction do create_project link_proposals end broadcast(:ok) end private attr_reader :project def create_project @project = Project.create!( scope: @form.scope, category: @form.category, feature: @form.current_feature, title: @form.title, short_description: @form.short_description, description: @form.description, budget: @form.budget ) end def proposals @proposals ||= project.sibling_scope(:proposals).where(id: @form.proposal_ids) end def link_proposals project.link_resources(proposals, "included_proposals") end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decidim-budgets-0.0.3 | app/commands/decidim/budgets/admin/create_project.rb |
decidim-0.0.3 | decidim-budgets/app/commands/decidim/budgets/admin/create_project.rb |