Sha256: 88045d37056cb70c98066ab18ec7e5e183ba1a1cb97b2d09e9819cfcadefdb04

Contents?: true

Size: 1.08 KB

Versions: 12

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

12 entries across 12 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.8 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.7 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.6 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.5 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.4 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.3 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.2 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.1 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.0 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.0.rc2 app/commands/decidim/votings/census/admin/destroy_dataset.rb
decidim-elections-0.27.0.rc1 app/commands/decidim/votings/census/admin/destroy_dataset.rb