Sha256: d36194e5f0f0a56d51b66ffc0aa79399b7e967f77dc38b1623c9db7c650fbb39

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# Recreate validations to take into account custom fields and ignore the length limit in proposals
module Decidim
  module ActionDelegator
    module Consultations
      module VoteQuestionOverride
        extend ActiveSupport::Concern

        included do
          private

          def build_vote
            if delegation
              form.context.delegation = delegation
              Decidim::ActionDelegator::VoteDelegation.new(form.response, form.context).call
            else
              vote = form.context.current_question.votes.build(
                author: form.context.current_user,
                response: form.response
              )
              Decidim::ActionDelegator::UnversionedVote.new(vote)
            end
          end

          def delegation
            @delegation ||= Decidim::ActionDelegator::GranteeDelegations.for(
              form.context.current_question.consultation,
              form.context.current_user
            ).find_by(id: form.decidim_consultations_delegation_id)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-action_delegator-0.6.0 app/commands/decidim/action_delegator/consultations/vote_question_override.rb
decidim-action_delegator-0.5.0 app/commands/decidim/action_delegator/consultations/vote_question_override.rb
decidim-action_delegator-0.4.1 app/commands/decidim/action_delegator/consultations/vote_question_override.rb
decidim-action_delegator-0.4 app/commands/decidim/action_delegator/consultations/vote_question_override.rb