Class: Decidim::Conferences::Admin::UpdateDiploma

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

Overview

This command is executed when the user updates the conference diploma configuration.

Instance Method Summary collapse

Constructor Details

#initialize(form, conference) ⇒ UpdateDiploma

Initializes a UpdateDiploma Command.

form - The form from which to get the data. conference - The current instance of the conference to be updated.


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

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

Instance Method Details

#callObject

Updates the conference if valid.

Broadcasts :ok if successful, :invalid otherwise.


20
21
22
23
24
25
26
27
28
29
30
31
# File 'decidim-conferences/app/commands/decidim/conferences/admin/update_diploma.rb', line 20

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

    update_conference_diploma
    Decidim.traceability.perform_action!(:update_diploma, @conference, form.current_user) do
      @conference
    end
  end

  broadcast(:ok)
end