Sha256: 8fa7bdf23073ac753caea4179675e6e328f1ee7038d33d3052adc687b0eece89

Contents?: true

Size: 1.3 KB

Versions: 44

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # This command is executed when the user updates a polling station
      # from the admin panel.
      class UpdatePollingStation < ManagePollingStation
        def initialize(form, polling_station)
          @form = form
          @polling_station = polling_station
        end

        # Updates the polling station if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        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

        private

        attr_reader :form, :polling_station

        def update_polling_station!
          attributes = {
            title: form.title,
            address: form.address,
            latitude: form.latitude,
            longitude: form.longitude,
            location: form.location,
            location_hints: form.location_hints
          }

          Decidim.traceability.update!(
            polling_station,
            form.current_user,
            attributes,
            visibility: "all"
          )
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.9 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.28.3 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.8 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.28.2 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.7 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.28.1 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.6 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.26.10 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.26.9 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.28.0 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.5 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.26.8 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.4 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.3 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.26.7 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.26.5 app/commands/decidim/votings/admin/update_polling_station.rb
decidim-elections-0.27.2 app/commands/decidim/votings/admin/update_polling_station.rb