1 class IssuesController < ApplicationController
4 before_action :authorize_web
5 before_action :require_user
6 before_action :check_permission, only: [:index, :show, :resolve,:open,:ignore,:comment]
7 before_action :find_issue, only: [:show, :resolve, :reopen, :ignore]
14 @read_reports = @issue.read_reports
15 @unread_reports = @issue.unread_reports
16 @comments = @issue.comments
20 unless create_new_issue_params.blank?
21 @issue = Issue.find_or_initialize_by(create_new_issue_params)
22 puts params[:user_id].to_s + "--------------"
27 @issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
29 @issue = Issue.find_or_initialize_by(issue_params)
30 @admins = UserRole.where(role: "administrator")
31 @admins.each do |admin|
32 Notifier.new_issue_notification(User.find(admin.user_id)).deliver_now
35 @report = @issue.reports.build(report_params)
36 @report.user_id = @user.id
38 redirect_to root_path, notice: 'Issue was successfully created.'
45 @issue = Issue.find(params[:id])
46 @issue_comment = @issue.comments.build(issue_comment_params)
47 @issue_comment.user_id = @user.id
56 redirect_to @issue, notice: "Issue status has been set to: 'Resolved'"
65 redirect_to @issue, notice: "Issue status has been set to: 'Ignored'"
74 redirect_to @issue, notice: "Issue status has been set to: 'Open'"
83 @issue = Issue.find(params[:id])
87 unless @user.administrator?
88 flash[:error] = t("application.require_admin.not_an_admin")
93 def create_new_issue_params
94 params.permit(:reportable_id, :reportable_type, :user_id)
98 params[:issue].permit(:reportable_id, :reportable_type,:user_id)
102 params[:report].permit(:details)
105 def issue_comment_params
106 params.require(:issue_comment).permit(:body, :user_id)