X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/8dc8479e12b50878ca6b476a4dd72fe1da1f24ad..e0faf6843746464d85a0cfbfc071226c2d62148d:/app/controllers/issues_controller.rb?ds=sidebyside diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 3f28ec44f..b636b981c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -6,7 +6,6 @@ class IssuesController < ApplicationController before_action :set_issues before_action :check_permission, :only => [:index, :show, :resolve, :open, :ignore, :comment] before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore] - before_action :setup_user_role, :only => [:show, :index] def index if current_user.moderator? @@ -17,7 +16,7 @@ class IssuesController < ApplicationController @users = User.joins(:roles).where(:user_roles => { :role => "administrator" }) end - @issues = Issue.where(:assigned_role => @user_role) + @issues = Issue.where(:assigned_role => current_user.roles.map(&:role)) # If search if params[:search_by_user] && params[:search_by_user].present? @@ -55,7 +54,7 @@ class IssuesController < ApplicationController @read_reports = @issue.read_reports @unread_reports = @issue.unread_reports @comments = @issue.comments - @related_issues = @issue.reported_user.issues.where(:assigned_role => @user_role) + @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) @new_comment = IssueComment.new(:issue => @issue) end @@ -130,11 +129,6 @@ class IssuesController < ApplicationController @moderator_issues = %w[Changeset Note] end - def setup_user_role - # Get user role - @user_role = current_user.administrator? ? "administrator" : "moderator" - end - def check_if_updated if @issue.reportable && (@issue.ignored? || @issue.resolved?) && @issue.reportable.has_attribute?(:updated_by) && @issue.reportable.updated_at > @last_report.updated_at true