1module PetitionHelper |
|
|
2 def public_petition_facets_with_counts(petition_search) |
3 petition_search.facets.slice(*public_petition_facets)
|
|
4 end |
|
|
6 def current_threshold(petition) |
7 if petition.response_threshold_reached_at? || petition.government_response_at? |
|
8 Site.threshold_for_debate |
|
9 else |
|
10 Site.threshold_for_response |
|
11 end |
|
12 end |
|
|
14 def signatures_threshold_percentage(petition) |
15 threshold = current_threshold(petition).to_f
|
|
16 percentage = petition.signature_count / threshold * 100 |
|
17 if percentage > 100 |
|
18 percentage = 100 |
|
19 elsif percentage < 1 |
|
20 percentage = 1 |
|
21 end |
|
22 number_to_percentage(percentage, precision: 2) |
|
23 end |
|
|
25 def petition_list_header |
26 @_petition_list_header ||= t(@petitions.scope, scope: :"petitions.list_headers", default: "") |
|
27 end |
|
|
29 def petition_list_header? |
30 petition_list_header.present?
|
|
31 end |
|
|
33 def reveal_government_response? |
34 params[:reveal_response] == "yes" |
|
35 end |
|
36end |