1 class IssuesController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
6 before_action :check_database_readable
10 before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
11 before_action :check_database_writable, :only => [:resolve, :ignore, :reopen]
17 @issue_types.push("Note") if current_user.moderator?
18 @issue_types.push("DiaryEntry", "DiaryComment", "User") if current_user.administrator?
20 @users = User.joins(:roles).where(:user_roles => { :role => current_user.roles.map(&:role) }).distinct
21 @issues = Issue.visible_to(current_user)
24 if params[:search_by_user]&.present?
25 @find_user = User.find_by(:display_name => params[:search_by_user])
27 @issues = @issues.where(:reported_user_id => @find_user.id)
29 @issues = @issues.none
30 flash.now[:warning] = t(".user_not_found")
34 @issues = @issues.where(:status => params[:status]) if params[:status]&.present?
36 @issues = @issues.where(:reportable_type => params[:issue_type]) if params[:issue_type]&.present?
38 if params[:last_updated_by]&.present?
39 last_updated_by = params[:last_updated_by].to_s == "nil" ? nil : params[:last_updated_by].to_i
40 @issues = @issues.where(:updated_by => last_updated_by)
45 @read_reports = @issue.read_reports
46 @unread_reports = @issue.unread_reports
47 @comments = @issue.comments
48 @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) if @issue.reported_user
49 @new_comment = IssueComment.new(:issue => @issue)
55 @issue.updated_by = current_user.id
57 redirect_to @issue, :notice => t(".resolved")
65 @issue.updated_by = current_user.id
67 redirect_to @issue, :notice => t(".ignored")
75 @issue.updated_by = current_user.id
77 redirect_to @issue, :notice => t(".reopened")
86 @issue = Issue.visible_to(current_user).find(params[:id])
87 rescue ActiveRecord::RecordNotFound
88 redirect_to :controller => "errors", :action => "not_found"