aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/widgets_controller.rb4
-rw-r--r--app/views/widgets/show.html.erb9
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>