]> git.openstreetmap.org Git - rails.git/commitdiff
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 e3c844d45e703f59eee29300b70d5970e6610ac4..346755fe3c015fc2a56df3e80785aebfe3323a3e 100644 (file)
@@ -11,7 +11,7 @@ class IssuesController < ApplicationController
   helper_method :sort_column, :sort_direction
 
   def index
   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
       @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
     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
       @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
     @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)
 
       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
 
         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)
       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!
       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
       @issue.save!
       notice = t("issues.comment.comment_created")
     end
@@ -175,7 +175,7 @@ class IssuesController < ApplicationController
 
   def ignore
     if @issue.ignore
 
   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
       @issue.save!
       redirect_to @issue, :notice => t("issues.ignored")
     else
@@ -185,7 +185,7 @@ class IssuesController < ApplicationController
 
   def reopen
     if @issue.reopen
 
   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
       @issue.save!
       redirect_to @issue, :notice => t("issues.reopened")
     else
@@ -216,7 +216,7 @@ class IssuesController < ApplicationController
 
   def setup_user_role
     # Get user role
 
   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
   end
 
   def check_if_updated
@@ -240,7 +240,7 @@ class IssuesController < ApplicationController
   end
 
   def check_permission
   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
       flash[:error] = t("application.require_admin.not_an_admin")
       redirect_to root_path
     end
index be00868632d58eb125cf961975a839456a6bdd86..1fb1e74a43c05b1fc831e4cb7b6ede391761b0ae 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) %>
 <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 %>
     <%= 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 0884e3bdfc420690ce728d71ce24f0a77de3a41d..a7dee697bb5b8cbb7b4a21a1361c69b16fa95579 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 %>
 <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 %>
     <%= 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 9ea035ba5ea8a9cd1a64618ef85f40d3934761ee..a6cf08888565f5cca75c3626a65eb32d912758b2 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}"))) %>
 <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 %>
       <%= 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 e3bb20e36372b277f39612b4c678ea76cf06b8f9..496d07c9ebef7efa3765fa9e32ce8dcf50440a93 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>
 
 
     <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 %>
            <%= 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 af9409662e19af58e749b82686232b72152a5e40..6c684c253b190a7c8899df9ba6fd297506b06060 100644 (file)
@@ -20,7 +20,7 @@
 </div>
 <br/>
 <div class="comment">
 </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/>
   <%= 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 a6bc4c6f7697691dcd029650510db133dbeeb5c2..09671b2c9fc95c7d8e8ef0c86cde6385229820cc 100644 (file)
@@ -38,7 +38,7 @@
   </nav>
   <nav class='secondary'>
     <ul>
   </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>
         <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 777f16389b47b99a132f68d2b7a557e1b8e02bd0..68f27ca38fcb50d13f9678b8f331df2ca446db6a 100644 (file)
       </p>
     </div>
 
       </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;
       <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;