Class: Decidim::Budgets::Admin::UpdateProject
- Inherits:
-
Command
- Object
- Command
- Decidim::Budgets::Admin::UpdateProject
- Includes:
- GalleryMethods
- Defined in:
- app/commands/decidim/budgets/admin/update_project.rb
Overview
This command is executed when the user changes a Project from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Updates the project if valid.
-
#initialize(form, project) ⇒ UpdateProject
constructor
Initializes an UpdateProject Command.
Constructor Details
#initialize(form, project) ⇒ UpdateProject
Initializes an UpdateProject Command.
form - The form from which to get the data. project - The current instance of the project to be updated.
15 16 17 18 19 |
# File 'app/commands/decidim/budgets/admin/update_project.rb', line 15 def initialize(form, project) @form = form @project = project @attached_to = project end |
Instance Method Details
#call ⇒ Object
Updates the project if valid.
Broadcasts :ok if successful, :invalid otherwise.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/commands/decidim/budgets/admin/update_project.rb', line 24 def call return broadcast(:invalid) if form.invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do update_project link_proposals create_gallery if process_gallery? photo_cleanup! end broadcast(:ok) end |