Class: Decidim::Budgets::Admin::CreateProject
- Inherits:
-
Command
- Object
- Command
- Decidim::Budgets::Admin::CreateProject
- Includes:
- AttachmentMethods, GalleryMethods
- Defined in:
- decidim-budgets/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
-
#call ⇒ Object
Creates the project if valid.
-
#initialize(form) ⇒ CreateProject
constructor
A new instance of CreateProject.
Constructor Details
#initialize(form) ⇒ CreateProject
Returns a new instance of CreateProject.
12 13 14 |
# File 'decidim-budgets/app/commands/decidim/budgets/admin/create_project.rb', line 12 def initialize(form) @form = form end |
Instance Method Details
#call ⇒ Object
Creates the project if valid.
Broadcasts :ok if successful, :invalid otherwise.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'decidim-budgets/app/commands/decidim/budgets/admin/create_project.rb', line 19 def call return broadcast(:invalid) if @form.invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do create_project! link_proposals create_gallery if process_gallery? end broadcast(:ok) end |