diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-04-23 14:31:35 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-04-28 09:07:26 +0100 |
commit | 080e9210cae1353f16449e3aff5f18ca62ee8a32 (patch) | |
tree | 45ab1aeba1113f33f1b964ca55b7bf108f230671 | |
parent | c2e0fb9ebfbbaa091806ad97c73930d6ca49b3bd (diff) |
Move vote calculation to controller.
-rw-r--r-- | app/controllers/widgets_controller.rb | 1 | ||||
-rw-r--r-- | app/views/widgets/show.html.erb | 3 |
2 files changed, 2 insertions, 2 deletions
diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb index d1953de10..2385855b1 100644 --- a/app/controllers/widgets_controller.rb +++ b/app/controllers/widgets_controller.rb @@ -15,6 +15,7 @@ class WidgetsController < ApplicationController medium_cache @track_thing = TrackThing.create_track_for_request(@info_request) @status = @info_request.calculate_status + @count = @info_request.track_things.count + @info_request.widget_votes.count + 1 unless @user or cookies[:widget_vote] cookies.permanent[:widget_vote] = SecureRandom.hex(10) end diff --git a/app/views/widgets/show.html.erb b/app/views/widgets/show.html.erb index 1dd8969b6..fde5f33f6 100644 --- a/app/views/widgets/show.html.erb +++ b/app/views/widgets/show.html.erb @@ -14,8 +14,7 @@ </div> </div> <div class="alaveteli-widget__people-count"> - <% count = TrackThing.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) + 1 + WidgetVote.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) %> - <%= n_('<div class="alaveteli-widget__count">{{count}}</div> person wants to know', '<div class="alaveteli-widget__count">{{count}}</div> people want to know', count, :count => count) %> + <%= n_('<div class="alaveteli-widget__count">{{count}}</div> person wants to know', '<div class="alaveteli-widget__count">{{count}}</div> people want to know', @count, :count => @count) %> </div> </div> |