Use current_user instead of @user.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 2 Aug 2017 11:21:51 +0000 (12:21 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 2 Aug 2017 11:21:51 +0000 (12:21 +0100)
app/controllers/issues_controller.rb
app/views/browse/changeset.html.erb
app/views/browse/note.html.erb
app/views/diary_entry/_diary_comment.html.erb
app/views/diary_entry/_diary_entry.html.erb
app/views/issues/_comments.html.erb
app/views/layouts/_header.html.erb
app/views/user/view.html.erb

index e3c844d..346755f 100644 (file)
@@ -11,7 +11,7 @@ class IssuesController < ApplicationController
   helper_method :sort_column, :sort_direction
 
   def index
-    if @user.moderator?
+    if current_user.moderator?
       @issue_types = @moderator_issues
       @users = User.joins(:roles).where(:user_roles => { :role => "moderator" })
     else
@@ -86,7 +86,7 @@ class IssuesController < ApplicationController
     if check_report_params
       @report = @issue.reports.build(report_params)
       details = report_details
-      @report.reporter_user_id = @user.id
+      @report.reporter_user_id = current_user.id
       @report.details = details
       # Checking if instance has been updated since last report
       @last_report = @issue.reports.order(:updated_at => :desc).last
@@ -114,11 +114,11 @@ class IssuesController < ApplicationController
     @issue = Issue.find_by(issue_params)
     # Check if details provided are sufficient
     if check_report_params
-      @report = @issue.reports.where(:reporter_user_id => @user.id).first
+      @report = @issue.reports.where(:reporter_user_id => current_user.id).first
 
       if @report.nil?
         @report = @issue.reports.build(report_params)
-        @report.reporter_user_id = @user.id
+        @report.reporter_user_id = current_user.id
         notice = t("issues.update.new_report")
       end
 
@@ -150,13 +150,13 @@ class IssuesController < ApplicationController
       notice = t("issues.comment.provide_details")
     else
       @issue_comment = @issue.comments.build(issue_comment_params)
-      @issue_comment.commenter_user_id = @user.id
+      @issue_comment.commenter_user_id = current_user.id
       if params[:reassign]
         reassign_issue
         @issue_comment.reassign = true
       end
       @issue_comment.save!
-      @issue.updated_by = @user.id
+      @issue.updated_by = current_user.id
       @issue.save!
       notice = t("issues.comment.comment_created")
     end
@@ -175,7 +175,7 @@ class IssuesController < ApplicationController
 
   def ignore
     if @issue.ignore
-      @issue.updated_by = @user.id
+      @issue.updated_by = current_user.id
       @issue.save!
       redirect_to @issue, :notice => t("issues.ignored")
     else
@@ -185,7 +185,7 @@ class IssuesController < ApplicationController
 
   def reopen
     if @issue.reopen
-      @issue.updated_by = @user.id
+      @issue.updated_by = current_user.id
       @issue.save!
       redirect_to @issue, :notice => t("issues.reopened")
     else
@@ -216,7 +216,7 @@ class IssuesController < ApplicationController
 
   def setup_user_role
     # Get user role
-    @user_role = @user.administrator? ? "administrator" : "moderator"
+    @user_role = current_user.administrator? ? "administrator" : "moderator"
   end
 
   def check_if_updated
@@ -240,7 +240,7 @@ class IssuesController < ApplicationController
   end
 
   def check_permission
-    unless @user.administrator? || @user.moderator?
+    unless current_user.administrator? || current_user.moderator?
       flash[:error] = t("application.require_admin.not_an_admin")
       redirect_to root_path
     end
index be00868..1fb1e74 100644 (file)
@@ -3,7 +3,7 @@
 <h2>
   <a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
   <%= t('browse.changeset.title', :id => @changeset.id) %>
-  <% if @user and @user.id != @changeset.user.id %>
+  <% if current_user and current_user.id != @changeset.user.id %>
     <%= link_to new_issue_url(reportable_id: @changeset.id, reportable_type: @changeset.class.name, referer: request.fullpath), :title => t('browse.changeset.report') do %>
         &nbsp;&#9872;
     <% end %>
index 0884e3b..a7dee69 100644 (file)
@@ -3,7 +3,7 @@
 <h2>
   <a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
   <%= t "browse.note.#{@note.status}_title", :note_name => @note.id %>
-  <% if @user && @note.author && @user.id != @note.author.id %>
+  <% if current_user && @note.author && current_user.id != @note.author.id %>
     <%= link_to new_issue_url(reportable_id: @note.id, reportable_type: @note.class.name, referer: request.fullpath), :title => t('browse.note.report') do %>
         &nbsp;&#9872;
     <% end %>
index 9ea035b..a6cf088 100644 (file)
@@ -1,7 +1,7 @@
 <div class="clearfix diary-comment">
   <%= user_thumbnail diary_comment.user %>
   <p class="deemphasize comment-heading" id="comment<%= diary_comment.id %>"><%= raw(t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => link_to(l(diary_comment.created_at, :format => :friendly), :anchor => "comment#{diary_comment.id}"))) %>
-    <% if @user and diary_comment.user.id != @user.id %>
+    <% if current_user and diary_comment.user.id != current_user.id %>
       <%= link_to new_issue_url(reportable_id: diary_comment.id, reportable_type: diary_comment.class.name, referer: request.fullpath), :title => t('diary_entry.diary_comment.report') do %>
               &nbsp;&#9872;
       <% end %>
index e3bb20e..496d07c 100644 (file)
@@ -6,7 +6,7 @@
 
     <h2><%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %></h2>
 
-    <% if @user and diary_entry.user.id != @user.id %>
+    <% if current_user and diary_entry.user.id != current_user.id %>
            <%= link_to new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, referer: request.fullpath), :title => t('diary_entry.diary_entry.report') do %>
             &nbsp;&#9872;
           <% end %>
index af94096..6c684c2 100644 (file)
@@ -20,7 +20,7 @@
 </div>
 <br/>
 <div class="comment">
-  <%= form_for :issue_comment, :url => { :action => 'comment', :id => @issue.id, :user_id => @user.id } do |f| %>
+  <%= form_for :issue_comment, :url => { :action => 'comment', :id => @issue.id, :user_id => current_user.id } do |f| %>
   <%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8, :required => true %>
   <%= label_tag t('issues.show.comments.reassign_param') %> <%= check_box_tag :reassign, true %>
   <br/>
index a6bc4c6..09671b2 100644 (file)
@@ -38,7 +38,7 @@
   </nav>
   <nav class='secondary'>
     <ul>
-      <% if @user and ( @user.administrator? or @user.moderator? ) %>
+      <% if current_user and ( current_user.administrator? or current_user.moderator? ) %>
         <li class="compact-hide <%= current_page_class(issues_path) %>"><b><%= link_to t('layouts.reports'), issues_path %></b></li>
       <% end %>
       <li class="compact-hide <%= current_page_class(traces_path) %>"><%= link_to t('layouts.gps_traces'), traces_path %></li>
index 777f163..68f27ca 100644 (file)
       </p>
     </div>
 
-    <% if @user and @this_user.id != @user.id %>
+    <% if current_user and @this_user.id != current_user.id %>
       <div class="report-button">
          <%= link_to new_issue_url(reportable_id: @this_user.id, reportable_type: @this_user.class.name, referer: request.fullpath), :title => t('user.view.report') do%>
             &nbsp;&#9872;