Class: Decidim::ActionDelegator::Delegation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::ActionDelegator::Delegation
- Defined in:
- app/models/decidim/action_delegator/delegation.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.granted_to?(user, consultation) ⇒ Boolean
27 28 29 |
# File 'app/models/decidim/action_delegator/delegation.rb', line 27 def self.granted_to?(user, consultation) GranteeDelegations.for(consultation, user).exists? end |
Instance Method Details
#grantee_voted? ⇒ Boolean
31 32 33 34 35 36 37 38 |
# File 'app/models/decidim/action_delegator/delegation.rb', line 31 def grantee_voted? return false unless consultation.questions.any? @grantee_voted ||= begin granter_votes = Decidim::Consultations::Vote.where(author: granter, question: consultation.questions) granter_votes&.detect { |vote| vote.versions.exists?(whodunnit: grantee&.id) } ? true : false end end |