Class: Decidim::Votings::Admin::UpdatePollingStation

Inherits:
ManagePollingStation show all
Defined in:
app/commands/decidim/votings/admin/update_polling_station.rb

Overview

This command is executed when the user updates a polling station from the admin panel.

Instance Method Summary collapse

Methods inherited from ManagePollingStation

#manage_polling_officers

Constructor Details

#initialize(form, polling_station) ⇒ UpdatePollingStation

Returns a new instance of UpdatePollingStation.



9
10
11
12
# File 'app/commands/decidim/votings/admin/update_polling_station.rb', line 9

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

Instance Method Details

#callObject

Updates the polling station if valid.

Broadcasts :ok if successful, :invalid otherwise.



17
18
19
20
21
22
23
24
# File 'app/commands/decidim/votings/admin/update_polling_station.rb', line 17

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

  update_polling_station!
  manage_polling_officers(polling_station, form.polling_station_president_id, form.polling_station_manager_ids)

  broadcast(:ok, polling_station)
end