Sha256: ef3101b364c4a60641fdd78ab98ebea33e06b6e1500a30a457895b837dfc5c6c

Contents?: true

Size: 983 Bytes

Versions: 18

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Census
      module Admin
        # A command to launch the access codes export
        class LaunchAccessCodesExport < Decidim::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?

            UpdateDataset.call(dataset, { status: :exporting_codes }, user)

            ExportAccessCodesJob.perform_later(dataset, user)

            broadcast(:ok)
          end

          attr_reader :user, :dataset

          private

          def valid?
            user.present? && dataset&.data&.exists? && dataset.codes_generated?
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.9 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.28.3 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.8 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.28.2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.7 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.28.1 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.6 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.28.0 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.5 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.4 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.3 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.1 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.0 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb
decidim-elections-0.27.0.rc2 app/commands/decidim/votings/census/admin/launch_access_codes_export.rb