Sha256: d06470adc17910257b72d6df1af7e1d1dbdb5f0ab72a881d1b1d99cb61f0bc88

Contents?: true

Size: 982 Bytes

Versions: 20

Compression:

Stored size: 982 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # This command is executed when the user destroys a polling station
      # from the admin panel.
      class DestroyPollingStation < Decidim::Command
        def initialize(polling_station, current_user)
          @polling_station = polling_station
          @current_user = current_user
        end

        # Destroys the polling station if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          destroy_polling_station!

          broadcast(:ok, polling_station)
        end

        private

        attr_reader :polling_station, :current_user

        def destroy_polling_station!
          Decidim.traceability.perform_action!(
            :delete,
            polling_station,
            current_user,
            visibility: "all"
          ) do
            polling_station.destroy!
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-elections-0.28.5 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.4 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.9 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.3 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.8 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.7 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.1 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.6 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.0 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.5 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.4 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.3 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.1 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.0 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.0.rc2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.27.0.rc1 app/commands/decidim/votings/admin/destroy_polling_station.rb