Class: Decidim::Consultation
Overview
The data store for a Consultation in the Decidim::Consultations component.
Class Method Summary
collapse
Instance Method Summary
collapse
#publish_results!, #results_published?, #unpublish_results!
Class Method Details
.order_randomly(seed) ⇒ Object
73
74
75
76
77
78
|
# File 'app/models/decidim/consultation.rb', line 73
def self.order_randomly(seed)
transaction do
connection.execute("SELECT setseed(#{connection.quote(seed)})")
select('"decidim_consultations".*, RANDOM()').order(Arel.sql("RANDOM()")).load
end
end
|
Instance Method Details
#active? ⇒ Boolean
48
49
50
|
# File 'app/models/decidim/consultation.rb', line 48
def active?
start_voting_date <= Time.now.utc && end_voting_date >= Time.now.utc
end
|
#finished? ⇒ Boolean
52
53
54
|
# File 'app/models/decidim/consultation.rb', line 52
def finished?
end_voting_date < Time.now.utc
end
|
#highlighted_questions ⇒ Object
56
57
58
|
# File 'app/models/decidim/consultation.rb', line 56
def highlighted_questions
questions.published.where(decidim_scope_id: decidim_highlighted_scope_id)
end
|
#questions_by_scope ⇒ Object
60
61
62
|
# File 'app/models/decidim/consultation.rb', line 60
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
69
70
71
|
# File 'app/models/decidim/consultation.rb', line 69
def scope
nil
end
|
#to_param ⇒ Object
40
41
42
|
# File 'app/models/decidim/consultation.rb', line 40
def to_param
slug
end
|
#upcoming? ⇒ Boolean
44
45
46
|
# File 'app/models/decidim/consultation.rb', line 44
def upcoming?
start_voting_date > Time.now.utc
end
|