Class: Moderate::AppealsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/moderate/appeals_controller.rb

Overview

Public DSA Art. 20 internal complaint form for moderation decisions.

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/moderate/appeals_controller.rb', line 25

def create
  @report = Moderate::Report.locate_signed_appeal_report(params[:token])
  return redirect_to appeal_return_path, alert: t("moderate.appeals.not_found", default: "We couldn't find that moderation decision.") if @report.blank?

  attributes = appeal_params
  attributes[:source] = appeal_source_for(@report, attributes[:source])

  intake = Moderate::Services::IntakeAppeal.new(
    appeal: Moderate::Appeal.new(attributes),
    report: @report,
    appellant: current_appellant
  )
  @appeal = intake.appeal

  if intake.save
    redirect_to appeal_return_path,
      notice: t("moderate.appeals.received", default: "Appeal received. A human reviewer will assess the decision."),
      status: :see_other
  else
    render :new, status: :unprocessable_entity
  end
end

#newObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/moderate/appeals_controller.rb', line 12

def new
  @report = Moderate::Report.locate_signed_appeal_report(params[:token])
  return redirect_to appeal_return_path, alert: t("moderate.appeals.not_found", default: "We couldn't find that moderation decision.") if @report.blank?

  @appeal = Moderate::Appeal.new(
    report: @report,
    appellant: current_appellant,
    appellant_name: current_appellant_name,
    appellant_email: current_appellant_email,
    source: appeal_source_for(@report, params[:source])
  )
end