1 class IssuesController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
9 before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
15 @issue_types.concat %w[Note] if current_user.moderator?
16 @issue_types.concat %w[DiaryEntry DiaryComment User] if current_user.administrator?
18 @users = User.joins(:roles).where(:user_roles => { :role => current_user.roles.map(&:role) }).distinct
19 @issues = Issue.visible_to(current_user)
22 if params[:search_by_user]&.present?
23 @find_user = User.find_by(:display_name => params[:search_by_user])
25 @issues = @issues.where(:reported_user_id => @find_user.id)
27 @issues = @issues.none
28 flash.now[:warning] = t(".user_not_found")
32 @issues = @issues.where(:status => params[:status]) if params[:status]&.present?
34 @issues = @issues.where(:reportable_type => params[:issue_type]) if params[:issue_type]&.present?
36 if params[:last_updated_by]&.present?
37 last_updated_by = params[:last_updated_by].to_s == "nil" ? nil : params[:last_updated_by].to_i
38 @issues = @issues.where(:updated_by => last_updated_by)
43 @read_reports = @issue.read_reports
44 @unread_reports = @issue.unread_reports
45 @comments = @issue.comments
46 @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) if @issue.reported_user
47 @new_comment = IssueComment.new(:issue => @issue)
54 redirect_to @issue, :notice => t(".resolved")
62 @issue.updated_by = current_user.id
64 redirect_to @issue, :notice => t(".ignored")
72 @issue.updated_by = current_user.id
74 redirect_to @issue, :notice => t(".reopened")
83 @issue = Issue.visible_to(current_user).find(params[:id])
84 rescue ActiveRecord::RecordNotFound