def index
if @user.moderator?
@issue_types = @moderator_issues
+ @users = User.joins(:roles).where(user_roles: {role: 'moderator'})
else
@issue_types = @admin_issues
+ @users = User.joins(:roles).where(user_roles: {role: 'administrator'})
end
@issues = Issue.where(issue_type: @user_role).order(sort_column + " " + sort_direction)
@issues = @issues.where(reportable_type: params[:issue_type][0])
end
+ # If last_updated_by
+ if params[:last_updated_by] and !params[:last_updated_by][0].blank?
+ last_reported_by = params[:last_updated_by][0].to_s == "nil" ? nil : params[:last_updated_by][0].to_i
+ @issues = @issues.where(updated_by: last_updated_by)
+ end
+
if @issues.first == nil
notice = t('issues.index.search.issues_not_found')
end
+ if params[:last_reported_by] and !params[:last_reported_by][0].blank?
+ last_reported_by = params[:last_reported_by][0].to_s == "nil" ? nil : params[:last_reported_by][0].to_i
+ @issues = @issues.where(updated_by: last_reported_by)
+ end
+
if notice
redirect_to issues_path, notice: notice
end
@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)
+ flash[:referer] = params[:referer]
end
end
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
-
end
# Check if details provided are sufficient
if @issue.save!
@issue.report_count = @issue.reports.count
@issue.save!
- redirect_to root_path, notice: t('issues.create.successful_report')
+
+ @admins_or_mods = UserRole.where(role: @issue.issue_type)
+ @admins_or_mods.each do |user|
+ Notifier.new_issue_notification(@issue.id, User.find(user.user_id)).deliver_now
+ end
+
+ redirect_to flash[:referer], notice: t('issues.create.successful_report')
end
else
redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.create.provide_details')
if @report.save!
@issue.report_count = @issue.reports.count
@issue.save!
- redirect_to root_path, notice: notice
+ redirect_to flash[:referer], notice: notice
end
else
redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.update.provide_details')