Sha256: 90256c93591fc37dc47e013e519ea6a82570a97a17b69ff9f4e74afd78e517ec

Contents?: true

Size: 982 Bytes

Versions: 25

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 < Rectify::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

25 entries across 25 versions & 1 rubygems

Version Path
decidim-elections-0.26.10 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.9 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.8 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.7 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.5 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.4 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.3 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.1 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.0 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.0.rc2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.26.0.rc1 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.1 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.0 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.0.rc4 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.0.rc3 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.0.rc2 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.25.0.rc1 app/commands/decidim/votings/admin/destroy_polling_station.rb
decidim-elections-0.24.3 app/commands/decidim/votings/admin/destroy_polling_station.rb