Sha256: 6d9887e3cab4a2447b5708c604b12fc2a49a14b0ad8d0fcf2989662718e2d4d6

Contents?: true

Size: 854 Bytes

Versions: 50

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    module Workflows
      # This Workflow allows users to vote in any budget, but only in one.
      class One < Base
        # No budget resource is highlighted for this workflow.
        def highlighted?(_resource)
          false
        end

        # Users can vote in any budget with this workflow, but only in one.
        def vote_allowed?(resource, consider_progress: true)
          return false if voted.any?

          if consider_progress
            progress?(resource) || progress.none?
          else
            true
          end
        end

        # Public: Returns a list of budgets where the user can discard their order to vote in another.
        #
        # Returns Array.
        def discardable
          progress + voted
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
decidim-budgets-0.29.1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.4 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.9 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.29.0 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.3 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.8 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.29.0.rc4 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.29.0.rc3 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.29.0.rc2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.29.0.rc1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.7 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.6 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.10 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.9 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.0 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.5 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.0.rc5 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.28.0.rc4 lib/decidim/budgets/workflows/one.rb