Class: Decidim::Consultation
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Decidim::Consultation
show all
- Includes:
- Decidim::Consultations::PublicableResults, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, Randomable, Resourceable, Searchable, Traceable
- Defined in:
- app/models/decidim/consultation.rb
Overview
The data store for a Consultation in the Decidim::Consultations component.
Instance Method Summary
collapse
#publish_results!, #results_published?, #unpublish_results!
Instance Method Details
#active? ⇒ Boolean
63
64
65
|
# File 'app/models/decidim/consultation.rb', line 63
def active?
start_voting_date <= Time.now.utc && end_voting_date >= Time.now.utc
end
|
#closed? ⇒ Boolean
96
97
98
|
# File 'app/models/decidim/consultation.rb', line 96
def closed?
!active?
end
|
#finished? ⇒ Boolean
67
68
69
|
# File 'app/models/decidim/consultation.rb', line 67
def finished?
end_voting_date < Time.now.utc
end
|
#highlighted_questions ⇒ Object
71
72
73
|
# File 'app/models/decidim/consultation.rb', line 71
def highlighted_questions
questions.published.where(decidim_scope_id: decidim_highlighted_scope_id)
end
|
#questions_by_scope ⇒ Object
75
76
77
|
# File 'app/models/decidim/consultation.rb', line 75
def questions_by_scope
questions.published.group_by(&:scope)
end
|
#scope ⇒ Object
This method exists with the only purpose of getting rid of whats seems to be an issue in the new scope picker: This engine is a bit special: consultations and questions are a kind of nested participatory spaces. When a new question is created the consultation is the participatory space. Since seems that the scope picker is asking to the current participatory space for its scope this method is necessary to exist an return nil in order to be able to browse the scope hierarchy
92
93
94
|
# File 'app/models/decidim/consultation.rb', line 92
def scope
nil
end
|
#to_param ⇒ Object
55
56
57
|
# File 'app/models/decidim/consultation.rb', line 55
def to_param
slug
end
|
#total_participants ⇒ Object
83
84
85
|
# File 'app/models/decidim/consultation.rb', line 83
def total_participants
@total_participants ||= questions.published.joins(:votes).select(:decidim_author_id).distinct.count
end
|
#total_votes ⇒ Object
79
80
81
|
# File 'app/models/decidim/consultation.rb', line 79
def total_votes
@total_votes ||= questions.published.sum(:votes_count)
end
|
#upcoming? ⇒ Boolean
59
60
61
|
# File 'app/models/decidim/consultation.rb', line 59
def upcoming?
start_voting_date > Time.now.utc
end
|