Sha256: 402b2ef58cf86d821cb7ac317934354bfed8fb3f6c01509fa7d2e45f12e2f57b

Contents?: true

Size: 1.31 KB

Versions: 25

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # A command with the business logic to destroy a poling officer
      class DestroyPollingOfficer < Rectify::Command
        # Public: Initializes the command.
        #
        # polling_officer - the PollingOfficer to destroy
        # current_user - the user performing this action
        def initialize(polling_officer, current_user)
          @polling_officer = polling_officer
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          destroy_polling_officer!
          broadcast(:ok)
        end

        private

        attr_reader :polling_officer, :current_user

        def destroy_polling_officer!
          extra_info = {
            resource: {
              title: polling_officer.user.name
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            polling_officer,
            current_user,
            extra_info
          ) do
            polling_officer.destroy!
            polling_officer
          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_officer.rb
decidim-elections-0.26.9 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.8 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.7 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.5 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.4 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.3 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.2 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.1 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.0 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.0.rc2 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.26.0.rc1 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.2 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.1 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.0 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.0.rc4 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.0.rc3 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.0.rc2 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.25.0.rc1 app/commands/decidim/votings/admin/destroy_polling_officer.rb
decidim-elections-0.24.3 app/commands/decidim/votings/admin/destroy_polling_officer.rb