From 1390cc194bd07b85fe36e31a0cab22981315974d Mon Sep 17 00:00:00 2001
From: ThibG <thib@sitedethib.com>
Date: Tue, 15 Dec 2020 04:30:15 +0100
Subject: [PATCH] Add indication to admin UI of whether a report has been
forwarded (#13237)
* Add indication to admin UI of whether a report has been forwarded
* Rework how forwarded status is displayed
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
---
app/models/report.rb | 1 +
app/services/report_service.rb | 3 ++-
app/views/admin/reports/index.html.haml | 4 ++++
app/views/admin/reports/show.html.haml | 10 ++++++++++
config/locales/en.yml | 2 ++
db/migrate/20200309150742_add_forwarded_to_reports.rb | 5 +++++
db/schema.rb | 1 +
7 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 db/migrate/20200309150742_add_forwarded_to_reports.rb
diff --git a/app/models/report.rb b/app/models/report.rb
index f31bcfd2e9..cd08120e41 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -14,6 +14,7 @@
# target_account_id :bigint(8) not null
# assigned_account_id :bigint(8)
# uri :string
+# forwarded :boolean
#
class Report < ApplicationRecord
diff --git a/app/services/report_service.rb b/app/services/report_service.rb
index 1e955c1e70..9d9c7d6c9f 100644
--- a/app/services/report_service.rb
+++ b/app/services/report_service.rb
@@ -24,7 +24,8 @@ class ReportService < BaseService
target_account: @target_account,
status_ids: @status_ids,
comment: @comment,
- uri: @options[:uri]
+ uri: @options[:uri],
+ forwarded: ActiveModel::Type::Boolean.new.cast(@options[:forward])
)
end
diff --git a/app/views/admin/reports/index.html.haml b/app/views/admin/reports/index.html.haml
index bb441380ec..721c55f71a 100644
--- a/app/views/admin/reports/index.html.haml
+++ b/app/views/admin/reports/index.html.haml
@@ -59,6 +59,10 @@
= fa_icon('camera')
= report.media_attachments.count
+ - if report.forwarded?
+ ยท
+ = t('admin.reports.forwarded_to', domain: target_account.domain)
+
.report-card__summary__item__assigned
- if report.assigned_account.present?
= admin_account_link_to report.assigned_account
diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml
index 2681419ca2..b060c553f0 100644
--- a/app/views/admin/reports/show.html.haml
+++ b/app/views/admin/reports/show.html.haml
@@ -46,6 +46,16 @@
%td{ colspan: 2 }
- if @report.action_taken?
= table_link_to 'envelope-open', t('admin.reports.reopen'), admin_report_path(@report, outcome: 'reopen'), method: :put
+ - unless @report.target_account.local?
+ %tr
+ %th= t('admin.reports.forwarded')
+ %td{ colspan: 3 }
+ - if @report.forwarded.nil?
+ \-
+ - elsif @report.forwarded?
+ = t('simple_form.yes')
+ - else
+ = t('simple_form.no')
- if !@report.action_taken_by_account.nil?
%tr
%th= t('admin.reports.action_taken_by')
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 114f86fd11..3ff01ac86a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -517,6 +517,8 @@ en:
comment:
none: None
created_at: Reported
+ forwarded: Forwarded
+ forwarded_to: Forwarded to %{domain}
mark_as_resolved: Mark as resolved
mark_as_unresolved: Mark as unresolved
notes:
diff --git a/db/migrate/20200309150742_add_forwarded_to_reports.rb b/db/migrate/20200309150742_add_forwarded_to_reports.rb
new file mode 100644
index 0000000000..df278240ba
--- /dev/null
+++ b/db/migrate/20200309150742_add_forwarded_to_reports.rb
@@ -0,0 +1,5 @@
+class AddForwardedToReports < ActiveRecord::Migration[5.2]
+ def change
+ add_column :reports, :forwarded, :boolean
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2f9d369be2..55822a4b3d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -717,6 +717,7 @@ ActiveRecord::Schema.define(version: 2020_12_06_004238) do
t.bigint "target_account_id", null: false
t.bigint "assigned_account_id"
t.string "uri"
+ t.boolean "forwarded"
t.index ["account_id"], name: "index_reports_on_account_id"
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
end
--
GitLab