Sha256: 9191a50cfd657f751b30e89368f7f1c7f2b2564b9e80ca6bba1da1b192e54b46

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 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 < Decidim::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 was not valid and could not 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

8 entries across 8 versions & 1 rubygems

Version Path
decidim-elections-0.28.5 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.4 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.3 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.2 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.1 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.0 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/votings/census/admin/destroy_dataset.rb