Class: Decidim::Budgets::Admin::CreateProject

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/budgets/admin/create_project.rb

Overview

This command is executed when the user creates a Project from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateProject

Returns a new instance of CreateProject.



9
10
11
# File 'app/commands/decidim/budgets/admin/create_project.rb', line 9

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Creates the project if valid.

Broadcasts :ok if successful, :invalid otherwise.



16
17
18
19
20
21
22
23
24
25
# File 'app/commands/decidim/budgets/admin/create_project.rb', line 16

def call
  return broadcast(:invalid) if @form.invalid?

  transaction do
    create_project
    link_proposals
  end

  broadcast(:ok)
end