diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-04-23 14:35:39 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-04-28 09:07:27 +0100 |
commit | 871a3a7214ca8381bf29e47d1c79c7736f871798 (patch) | |
tree | a70ca88db9dea78c087ee17d80b76c6721d9346f | |
parent | 080e9210cae1353f16449e3aff5f18ca62ee8a32 (diff) |
Move existing track logic to controller
-rw-r--r-- | app/controllers/widgets_controller.rb | 4 | ||||
-rw-r--r-- | app/views/widgets/show.html.erb | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb index 2385855b1..04378a724 100644 --- a/app/controllers/widgets_controller.rb +++ b/app/controllers/widgets_controller.rb @@ -16,6 +16,10 @@ class WidgetsController < ApplicationController @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 + + if @user + @existing_track = TrackThing.find_existing(@user, @track_thing) + end 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 fde5f33f6..07c7b1908 100644 --- a/app/views/widgets/show.html.erb +++ b/app/views/widgets/show.html.erb @@ -19,18 +19,13 @@ </div> - <% - if @user - existing_track = TrackThing.find_existing(@user, @track_thing) - end - %> <div class="alaveteli-widget__bottom"> <% if @info_request.user && @info_request.user == @user %> <div class="alaveteli-widget__button alaveteli-widget__button--down"> <%= _('This is your request') %> </div> - <% elsif existing_track %> - <a href="<%= url_for :controller => 'track', :action => 'update', :track_id => existing_track.id, :track_medium => "delete", :r => request.fullpath %>"> + <% elsif @existing_track %> + <a href="<%= url_for :controller => 'track', :action => 'update', :track_id => @existing_track.id, :track_medium => "delete", :r => request.fullpath %>"> <div class="alaveteli-widget__button--down"> <%= _('You are tracking this request') %> </div> |