From 97ee2cd9757539e49b12f7b945f4226b699f6239 Mon Sep 17 00:00:00 2001 From: Lukas Matt Date: Sat, 3 Oct 2015 13:34:32 +0200 Subject: [PATCH] Display all reports and give the ability to review them --- app/controllers/report_controller.rb | 5 +-- app/views/report/index.html.haml | 49 +++++++++++++++++----------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb index 14e9001f1..8e0826c1f 100644 --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -7,10 +7,7 @@ class ReportController < ApplicationController before_action :redirect_unless_moderator, except: [:create] def index - @reports ||= [] - Report.where(reviewed: false).each do |report| - @reports << report unless report.item.nil? - end + @reports = Report.where(reviewed: false) end def update diff --git a/app/views/report/index.html.haml b/app/views/report/index.html.haml index 6a285874e..2df36adf8 100644 --- a/app/views/report/index.html.haml +++ b/app/views/report/index.html.haml @@ -11,23 +11,34 @@ %h1 = t("report.title") - @reports.each do |report| - .panel.panel-default - - username = report.user.username - .panel-heading - .reporter.pull-right - = raw t("report.reported_label", person: link_to(username, user_profile_path(username))) - .title - = report_content(report) - .panel-body - .reason - = t("report.reason_label", text: report.text) - - = button_to t("report.reported_user_details"), - user_search_path(admins_controller_user_search: {guid: report.reported_author.guid}), - class: "btn pull-left btn-info btn-small", method: :post - = button_to t("report.review_link"), report_path(report.id, type: report.item_type), - class: "btn pull-left btn-info btn-small", method: :put - = button_to t("report.delete_link"), report_path(report.id, type: report.item_type), - data: {confirm: t("report.confirm_deletion")}, - class: "btn pull-right btn-danger btn-small", method: :delete + - if report.item + .panel.panel-default + - username = report.user.username + .panel-heading + .reporter.pull-right + = raw t("report.reported_label", person: link_to(username, user_profile_path(username))) + .title + = report_content(report) + .panel-body + .reason + = t("report.reason_label", text: report.text) + = button_to t("report.reported_user_details"), + user_search_path(admins_controller_user_search: {guid: report.reported_author.guid}), + class: "btn pull-left btn-info btn-small", method: :post + = button_to t("report.review_link"), report_path(report.id, type: report.item_type), + class: "btn pull-left btn-info btn-small", method: :put + = button_to t("report.delete_link"), report_path(report.id, type: report.item_type), + data: {confirm: t("report.confirm_deletion")}, + class: "btn pull-right btn-danger btn-small", method: :delete + - else + .panel.panel-default + - username = report.user.username + .panel-heading + .reporter.pull-right + = raw t("report.reported_label", person: link_to(username, user_profile_path(username))) + .title + = report_content(report) + .panel-body + = button_to t("report.review_link"), report_path(report.id, type: report.item_type), + class: "btn pull-left btn-info btn-small", method: :put