Class: Decidim::Proposals::Admin::CreateProposalNote

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-proposals/app/commands/decidim/proposals/admin/create_proposal_note.rb

Overview

A command with all the business logic when an admin creates a private note proposal.

Instance Method Summary collapse

Constructor Details

#initialize(form, proposal) ⇒ CreateProposalNote

Public: Initializes the command.

form - A form object with the params. proposal - the proposal to relate.


12
13
14
15
# File 'decidim-proposals/app/commands/decidim/proposals/admin/create_proposal_note.rb', line 12

def initialize(form, proposal)
  @form = form
  @proposal = proposal
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid, together with the note proposal.

  • :invalid if the form wasn't valid and we couldn't proceed.

Returns nothing.


23
24
25
26
27
28
29
30
# File 'decidim-proposals/app/commands/decidim/proposals/admin/create_proposal_note.rb', line 23

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

  create_proposal_note
  notify_admins_and_valuators

  broadcast(:ok, proposal_note)
end