Class: RailsImagePostSolution::Admin::ImageReportsController
Instance Method Summary
collapse
#default_url_options, #require_admin, #require_login
Instance Method Details
#confirm ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/rails_image_post_solution/admin/image_reports_controller.rb', line 48
def confirm
@report.update!(
status: ImageReport::STATUSES[:confirmed],
reviewed_by: current_user,
reviewed_at: Time.current
)
redirect_to admin_image_reports_path, notice: I18n.t("rails_image_post_solution.flash.admin.report_confirmed")
end
|
#dismiss ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/rails_image_post_solution/admin/image_reports_controller.rb', line 58
def dismiss
@report.update!(
status: ImageReport::STATUSES[:dismissed],
reviewed_by: current_user,
reviewed_at: Time.current
)
redirect_to admin_image_reports_path, notice: I18n.t("rails_image_post_solution.flash.admin.report_dismissed")
end
|
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/rails_image_post_solution/admin/image_reports_controller.rb', line 10
def index
@status_filter = params[:status] || "all"
@reports = ImageReport.includes(:user, :active_storage_attachment, :reviewed_by)
.recent
case @status_filter
when "pending"
@reports = @reports.pending
when "confirmed"
@reports = @reports.confirmed
when "dismissed"
@reports = @reports.dismissed
when "reviewed"
@reports = @reports.reviewed
end
@reports = @reports.limit(100)
@stats = {
total: ImageReport.count,
pending: ImageReport.pending.count,
confirmed: ImageReport.confirmed.count,
dismissed: ImageReport.dismissed.count,
reviewed: ImageReport.reviewed.count
}
end
|
#show ⇒ Object
40
41
42
43
44
45
46
|
# File 'app/controllers/rails_image_post_solution/admin/image_reports_controller.rb', line 40
def show
@attachment = @report.active_storage_attachment
@reported_user = @attachment.record.user if @attachment.record.respond_to?(:user)
@all_reports = ImageReport.where(active_storage_attachment_id: @attachment.id)
.includes(:user)
.recent
end
|