Class: Decidim::Consultation
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Decidim::Consultation
show all
- Includes:
- Decidim::Consultations::PublicableResults, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, Randomable, Resourceable, 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
52
53
54
|
# File 'app/models/decidim/consultation.rb', line 52
def active?
start_voting_date <= Time.now.utc && end_voting_date >= Time.now.utc
end
|
#closed? ⇒ Boolean
85
86
87
|
# File 'app/models/decidim/consultation.rb', line 85
def closed?
!active?
end
|
#finished? ⇒ Boolean
56
57
58
|
# File 'app/models/decidim/consultation.rb', line 56
def finished?
end_voting_date < Time.now.utc
end
|
#highlighted_questions ⇒ Object
60
61
62
|
# File 'app/models/decidim/consultation.rb', line 60
def highlighted_questions
questions.published.where(decidim_scope_id: decidim_highlighted_scope_id)
end
|
#questions_by_scope ⇒ Object
64
65
66
|
# File 'app/models/decidim/consultation.rb', line 64
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
81
82
83
|
# File 'app/models/decidim/consultation.rb', line 81
def scope
nil
end
|
#to_param ⇒ Object
44
45
46
|
# File 'app/models/decidim/consultation.rb', line 44
def to_param
slug
end
|
#total_participants ⇒ Object
72
73
74
|
# File 'app/models/decidim/consultation.rb', line 72
def total_participants
@total_participants ||= questions.published.joins(:votes).select(:decidim_author_id).distinct.count
end
|
#total_votes ⇒ Object
68
69
70
|
# File 'app/models/decidim/consultation.rb', line 68
def total_votes
@total_votes ||= questions.published.sum(:votes_count)
end
|
#upcoming? ⇒ Boolean
48
49
50
|
# File 'app/models/decidim/consultation.rb', line 48
def upcoming?
start_voting_date > Time.now.utc
end
|