Sha256: e4d10db56ae6c745d28c4a387be939add2fb3c4d0e476f507ef561701fe86168

Contents?: true

Size: 869 Bytes

Versions: 20

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    # A command to check if census data is given
    class CheckCensus < Decidim::Command
      def initialize(form)
        @form = form
      end

      # Executes the command. Broadcast this events:
      # - :ok when census is found
      # - :invalid when the form is not valid
      # - :not_found when census is not found
      #
      # Returns nothing.
      def call
        return broadcast(:invalid) unless form.valid?

        check_census
      end

      attr_reader :form, :session

      def check_census
        datum = Decidim::Votings::Census::Datum.find_by(dataset: form.current_participatory_space.dataset, hashed_check_data: form.hashed_check_data)
        if datum
          broadcast(:ok, datum)
        else
          broadcast(:not_found)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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