From: Andy Allan Date: Wed, 2 Aug 2017 11:21:51 +0000 (+0100) Subject: Use current_user instead of @user. X-Git-Tag: live~2976^2~108 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3e4255eb2cc9f8b260ecab6d80c783723cf89d88?hp=e31376e28da8f656e33508cc899da465b63673c5 Use current_user instead of @user. --- diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e3c844d45..346755fe3 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -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 diff --git a/app/views/browse/changeset.html.erb b/app/views/browse/changeset.html.erb index be0086863..1fb1e74a4 100644 --- a/app/views/browse/changeset.html.erb +++ b/app/views/browse/changeset.html.erb @@ -3,7 +3,7 @@

<%= 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 %>  ⚐ <% end %> diff --git a/app/views/browse/note.html.erb b/app/views/browse/note.html.erb index 0884e3bdf..a7dee697b 100644 --- a/app/views/browse/note.html.erb +++ b/app/views/browse/note.html.erb @@ -3,7 +3,7 @@

<%= 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 %>  ⚐ <% end %> diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index 9ea035ba5..a6cf08888 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -1,7 +1,7 @@
<%= user_thumbnail diary_comment.user %>

<%= 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 %>  ⚐ <% end %> diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index e3bb20e36..496d07c9e 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -6,7 +6,7 @@

<%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>

- <% 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 %>  ⚐ <% end %> diff --git a/app/views/issues/_comments.html.erb b/app/views/issues/_comments.html.erb index af9409662..6c684c253 100644 --- a/app/views/issues/_comments.html.erb +++ b/app/views/issues/_comments.html.erb @@ -20,7 +20,7 @@

- <%= 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 %>
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index a6bc4c6f7..09671b2c9 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -38,7 +38,7 @@
- <% if @user and @this_user.id != @user.id %> + <% if current_user and @this_user.id != current_user.id %>
<%= 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%>  ⚐