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", "User") 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).order(:updated_at => :desc)
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 @title = t ".title", :status => @issue.status.humanize, :issue_id => @issue.id
46 @read_reports = @issue.read_reports
47 @unread_reports = @issue.unread_reports
48 @comments = @issue.comments
49 @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) if @issue.reported_user
50 @new_comment = IssueComment.new(:issue => @issue)
56 @issue.updated_by = current_user.id
58 redirect_to @issue, :notice => t(".resolved")
66 @issue.updated_by = current_user.id
68 redirect_to @issue, :notice => t(".ignored")
76 @issue.updated_by = current_user.id
78 redirect_to @issue, :notice => t(".reopened")
87 @issue = Issue.visible_to(current_user).find(params[:id])
88 rescue ActiveRecord::RecordNotFound
89 redirect_to :controller => "errors", :action => "not_found"