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])
51 @title = t ".title", :status => @issue.status.humanize, :issue_id => @issue.id
52 @read_reports = @issue.read_reports
53 @unread_reports = @issue.unread_reports
54 @comments = @issue.comments
55 @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) if @issue.reported_user
56 @new_comment = IssueComment.new(:issue => @issue)
62 @issue.updated_by = current_user.id
64 redirect_to @issue, :notice => t(".resolved")
72 @issue.updated_by = current_user.id
74 redirect_to @issue, :notice => t(".ignored")
82 @issue.updated_by = current_user.id
84 redirect_to @issue, :notice => t(".reopened")
93 @issue = Issue.visible_to(current_user).find(params[:id])
94 rescue ActiveRecord::RecordNotFound
95 redirect_to :controller => "errors", :action => "not_found"