Skip to content

Commit 7897f3c

Browse files
committed
various review comments
1 parent d44c3bc commit 7897f3c

16 files changed

+60
-128
lines changed

app/controllers/reports_controller.rb

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/controllers/request_for_comments_controller.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class RequestForCommentsController < ApplicationController
44
include CommonBehavior
5-
before_action :set_request_for_comment, only: %i[show mark_as_solved set_thank_you_note clear_question]
5+
before_action :set_request_for_comment, only: %i[show mark_as_solved set_thank_you_note clear_question report]
66
before_action :set_study_group_grouping,
77
only: %i[index my_comment_requests rfcs_with_my_comments rfcs_for_exercise]
88

@@ -162,6 +162,15 @@ def create
162162
authorize!
163163
end
164164

165+
# POST /request_for_comments/1/report
166+
def report
167+
authorize!
168+
169+
ReportMailer.with(reported_content: @request_for_comment).report_content.deliver_later
170+
171+
redirect_to(request_for_comment_path(@request_for_comment), notice: t('.report.reported'))
172+
end
173+
165174
private
166175

167176
# Use callbacks to share common setup or constraints between actions.

app/policies/report_policy.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/policies/request_for_comment_policy.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ def rfcs_with_my_comments?
4141
everyone
4242
end
4343

44+
def report?
45+
report_receiver_configured? && !author?
46+
end
47+
48+
private
49+
50+
def report_receiver_configured?
51+
CodeOcean::Config.new(:code_ocean).read.dig(:content_moderation, :report_emails).present?
52+
end
53+
4454
def rfc_visibility
4555
# The consumer with the most restricted visibility determines the visibility of the RfC
4656
case [@user.consumer.rfc_visibility, @record.author.consumer.rfc_visibility]

app/views/reports/_button.html.slim

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.text-end
2+
= button_to t('.report'), report_request_for_comment_path(request_for_comment),
3+
data: {confirm: t('.confirm')},
4+
class: 'btn btn-light btn-sm'

app/views/request_for_comments/show.html.slim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
.text
2929
- question = @request_for_comment.question
3030
= question.presence || t('request_for_comments.no_question')
31-
.text-end
32-
= render('reports/button', reported_content: @request_for_comment)
31+
- if policy(@request_for_comment).report?
32+
= render('report', request_for_comment: @request_for_comment)
3333

3434
- if policy(@request_for_comment).mark_as_solved? && !@request_for_comment.solved?
3535
= render('mark_as_solved')

config/locales/de/report.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ de:
55
prolog: 'Die folgenden Inhalte wurden als unangemessen gemeldet:'
66
subject: 'Spam Report: Ein %{content_name} in CodeOcean wurde als unangemessen markiert.'
77
take_action: Bitte ergreifen Sie gegebenenfalls Maßnahmen.
8-
reports:
9-
confirm: Möchten Sie diesen Inhalt melden?
10-
report: Melden
11-
reported: Vielen Dank, dass Sie uns auf dieses Problem aufmerksam gemacht haben. Wir werden uns in Kürze darum kümmern.

config/locales/de/request_for_comment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ de:
4242
no_output: Keine Ausgabe.
4343
no_question: Der/die Autor:in hat keine Frage zu dieser Anfrage gestellt.
4444
passed: Erfolgreich
45+
report:
46+
confirm: Möchten Sie diesen Inhalt melden?
47+
report: Melden
48+
reported: Vielen Dank, dass Sie uns auf dieses Problem aufmerksam gemacht haben. Wir werden uns in Kürze darum kümmern.
4549
runtime_output: Programmausgabe
4650
send_thank_you_note: Senden
4751
show_all: Alle Anfragen anzeigen

config/locales/en/report.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ en:
55
prolog: 'The following content has been reported as inappropriate:'
66
subject: 'Spam Report: A %{content_name} on CodeOcean has been marked as inappropriate.'
77
take_action: Please take action if required.
8-
reports:
9-
confirm: Do you want to report this content?
10-
report: Report
11-
reported: Thank you for letting us know about this issue. We will look into the matter shorty.

0 commit comments

Comments
 (0)