- @issues = Issue.where(issue_type: @user_role).order(:status)
- end
- end
-
- def show
- @read_reports = @issue.read_reports
- @unread_reports = @issue.unread_reports
- @comments = @issue.comments
- @related_issues = @issue.user.issues.where(issue_type: @user_role)
- if @issue.updated_by
- @updated_by_admin = User.find(@issue.updated_by)
- end
- end
-
- def new
- unless create_new_issue_params.blank?
- @issue = Issue.find_or_initialize_by(create_new_issue_params)
- path = 'issues.report_strings.' + @issue.reportable.class.name.to_s
- @report_strings_yaml = t(path)
- end
- end
-
- def create
-
- # TODO: Find better place to add these
- admin_issues = [ 'DiaryEntry', 'DiaryComment', 'User']
- moderator_issues = [ 'Changeset' ]
-
-
- @issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
- # Check if Issue alrwady exists
- if !@issue
- @issue = Issue.find_or_initialize_by(issue_params)
- @issue.updated_by = nil
-
- # Reassign to moderators if it is a moderator issue
- @issue.issue_type = "administrator"
- if moderator_issues.include? @issue.reportable.class.name
- reassign_issue
- end
-
- @admins_or_mods = UserRole.where(role: @issue.issue_type)
- @admins_or_mods.each do |user|
- Notifier.new_issue_notification(User.find(user.user_id)).deliver_now
- end
-