Sha256: 7547c10b425dc94def87149618b578bd5547cc5f7d6a33885b890ffe516ccb16

Contents?: true

Size: 907 Bytes

Versions: 19

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Census
      module Admin
        # A command to launch the access codes export
        class LaunchAccessCodesExport < Rectify::Command
          def initialize(dataset, user)
            @dataset = dataset
            @user = user
          end

          # Executes the command. Broadcast this events:
          # - :ok when everything is valid
          # - :invalid when the user is not present
          #
          # Returns nothing.
          def call
            return broadcast(:invalid) unless valid?

            ExportAccessCodesJob.perform_later(dataset, user)

            broadcast(:ok)
          end

          attr_reader :user, :dataset

          private

          def valid?
            user.present? && dataset&.data&.present? && dataset.codes_generated?
          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/launch_access_codes_export.rb
decidim-elections-0.26.9 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.8 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.7 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.5 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.4 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.3 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.1 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.0 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.0.rc2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.26.0.rc1 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.1 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.0 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.0.rc4 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.0.rc3 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.0.rc2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.25.0.rc1 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb