1 class IssuesController < ApplicationController
2 include PaginationMethods
6 before_action :authorize_web
7 before_action :set_locale
8 before_action :check_database_readable
12 before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
13 before_action :check_database_writable, :only => [:resolve, :ignore, :reopen]
16 @params = params.permit(:before, :after, :limit, :status, :search_by_user, :issue_type, :last_updated_by)
17 @params[:limit] ||= 50
21 @issue_types.push("Note", "User") if current_user.moderator?
22 @issue_types.push("DiaryEntry", "DiaryComment", "User") if current_user.administrator?
24 @users = User.joins(:roles).where(:user_roles => { :role => current_user.roles.map(&:role) }).distinct
25 @issues = Issue.visible_to(current_user)
28 if params[:search_by_user].present?
29 @find_user = User.find_by(:display_name => params[:search_by_user])
31 @issues = @issues.where(:reported_user => @find_user)
33 @issues = @issues.none
34 flash.now[:warning] = t(".user_not_found")
38 @issues = @issues.where(:status => params[:status]) if params[:status].present?
40 @issues = @issues.where(:reportable_type => params[:issue_type]) if params[:issue_type].present?
42 if params[:last_updated_by].present?
43 last_updated_by = params[:last_updated_by].to_s == "nil" ? nil : params[:last_updated_by].to_i
44 @issues = @issues.where(:updated_by => last_updated_by)
47 @issues, @newer_issues_id, @older_issues_id = get_page_items(@issues, :limit => @params[:limit])
48 render :partial => "page" if turbo_frame_request_id == "pagination"
52 @title = t ".title", :status => @issue.status.humanize, :issue_id => @issue.id
53 @read_reports = @issue.read_reports
54 @unread_reports = @issue.unread_reports
55 @comments = @issue.comments
56 @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) if @issue.reported_user
57 @new_comment = IssueComment.new(:issue => @issue)
63 @issue.updated_by = current_user.id
65 redirect_to @issue, :notice => t(".resolved")
73 @issue.updated_by = current_user.id
75 redirect_to @issue, :notice => t(".ignored")
83 @issue.updated_by = current_user.id
85 redirect_to @issue, :notice => t(".reopened")
94 @issue = Issue.visible_to(current_user).find(params[:id])
95 rescue ActiveRecord::RecordNotFound
96 redirect_to :controller => "errors", :action => "not_found"