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.26.8 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.4 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.3 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.7 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.5 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.4 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.0 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.3 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.0.rc2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.27.0.rc1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.0 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.0.rc2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.26.0.rc1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.25.2 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.25.1 lib/decidim/budgets/workflows/one.rb
decidim-budgets-0.25.0 lib/decidim/budgets/workflows/one.rb