Sha256: afb67a04a6c9b4c9a20cf3f571bdeeb1354a687390d02363f5a5ad7cbc8f8327

Contents?: true

Size: 1.08 KB

Versions: 19

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "csv"

module Decidim
  module Votings
    module Census
      module Admin
        # A command with the business logic to destroy a census dataset
        # from the admin panel.
        class DestroyDataset < Rectify::Command
          def initialize(dataset, current_user)
            @dataset = dataset
            @current_user = current_user
          end

          # Executes the command. Broadcast this events:
          # - :ok when everything is valid
          # - :invalid when the form wasn't valid and couldn't proceed-
          #
          # Returns nothing.
          def call
            return broadcast(:invalid) unless dataset || current_user

            destroy_census_dataset!

            broadcast(:ok)
          end

          attr_reader :dataset, :current_user

          def destroy_census_dataset!
            Decidim.traceability.perform_action!(
              :delete,
              dataset,
              current_user
            ) do
              dataset.destroy!
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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