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?
@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?
@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
@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