rails-image-post-solution 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8cff46842aaf17f3755a392ae1b340330bb15b54c94616db8ed96c646efcc468
|
|
4
|
+
data.tar.gz: c55be48295ec1c5366440b924b1101428f851d1fa913018eaed1bce968a434d6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b8f5fa256f33c94892be69b3c5aeed7b14cfd1be7a1451f79f8c574b5b53f0819acdf1a42b719be9dd24b591228c82eaaa016ad82e0d8e1def6ad94b9c37a97
|
|
7
|
+
data.tar.gz: c6843b246611dcb5db6445dad0e8d33b0acaad626140dd4b8445dda7db3fda1989b44f0c6305c987c707d9c95344195783a6353573ba67b3903f89c20bbeb805
|
|
@@ -9,6 +9,11 @@ module RailsImagePostSolution
|
|
|
9
9
|
# Explicitly set engine root
|
|
10
10
|
config.root = File.expand_path('../..', __dir__)
|
|
11
11
|
|
|
12
|
+
# Explicitly autoload the Admin module before controllers
|
|
13
|
+
config.before_initialize do
|
|
14
|
+
require_dependency Engine.root.join('app/controllers/rails_image_post_solution/admin.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
# Load routes when engine is initialized
|
|
13
18
|
config.after_initialize do
|
|
14
19
|
routes_path = RailsImagePostSolution::Engine.root.join("config", "routes.rb")
|
|
@@ -17,14 +22,14 @@ module RailsImagePostSolution
|
|
|
17
22
|
load routes_path
|
|
18
23
|
end
|
|
19
24
|
|
|
20
|
-
# After routes are loaded, make helpers available
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
# After routes are loaded, make helpers available directly
|
|
26
|
+
Rails.application.config.to_prepare do
|
|
27
|
+
# Include in all controllers
|
|
28
|
+
ActionController::Base.include RailsImagePostSolution::Engine.routes.url_helpers
|
|
29
|
+
ActionController::Base.helper RailsImagePostSolution::Engine.routes.url_helpers
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
include RailsImagePostSolution::Engine.routes.url_helpers
|
|
31
|
+
# Include in all views
|
|
32
|
+
ActionView::Base.include RailsImagePostSolution::Engine.routes.url_helpers
|
|
28
33
|
end
|
|
29
34
|
end
|
|
30
35
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-image-post-solution
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dhq_boiler
|
|
@@ -93,9 +93,9 @@ files:
|
|
|
93
93
|
- LICENSE.txt
|
|
94
94
|
- README.md
|
|
95
95
|
- Rakefile
|
|
96
|
+
- app/controllers/rails_image_post_solution/admin.rb
|
|
96
97
|
- app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb
|
|
97
98
|
- app/controllers/rails_image_post_solution/admin/image_reports_controller.rb
|
|
98
|
-
- app/controllers/rails_image_post_solution/admin/image_reports_controller.rb.bak
|
|
99
99
|
- app/controllers/rails_image_post_solution/admin/users_controller.rb
|
|
100
100
|
- app/controllers/rails_image_post_solution/image_reports_controller.rb
|
|
101
101
|
- app/jobs/rails_image_post_solution/image_moderation_job.rb
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Admin
|
|
4
|
-
class ImageReportsController < ApplicationController
|
|
5
|
-
before_action :require_login
|
|
6
|
-
before_action :require_admin
|
|
7
|
-
before_action :set_report, only: %i[show confirm dismiss]
|
|
8
|
-
|
|
9
|
-
def index
|
|
10
|
-
@status_filter = params[:status] || "all"
|
|
11
|
-
|
|
12
|
-
@reports = ImageReport.includes(:user, :active_storage_attachment, :reviewed_by)
|
|
13
|
-
.recent
|
|
14
|
-
|
|
15
|
-
# Filter by status
|
|
16
|
-
case @status_filter
|
|
17
|
-
when "pending"
|
|
18
|
-
@reports = @reports.pending
|
|
19
|
-
when "confirmed"
|
|
20
|
-
@reports = @reports.confirmed
|
|
21
|
-
when "dismissed"
|
|
22
|
-
@reports = @reports.dismissed
|
|
23
|
-
when "reviewed"
|
|
24
|
-
@reports = @reports.reviewed
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
@reports = @reports.limit(100)
|
|
28
|
-
|
|
29
|
-
# Statistics
|
|
30
|
-
@stats = {
|
|
31
|
-
total: ImageReport.count,
|
|
32
|
-
pending: ImageReport.pending.count,
|
|
33
|
-
confirmed: ImageReport.confirmed.count,
|
|
34
|
-
dismissed: ImageReport.dismissed.count,
|
|
35
|
-
reviewed: ImageReport.reviewed.count
|
|
36
|
-
}
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def show
|
|
40
|
-
@attachment = @report.active_storage_attachment
|
|
41
|
-
@reported_user = @attachment.record.user if @attachment.record.respond_to?(:user)
|
|
42
|
-
@all_reports = ImageReport.where(active_storage_attachment_id: @attachment.id)
|
|
43
|
-
.includes(:user)
|
|
44
|
-
.recent
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def confirm
|
|
48
|
-
@report.update!(
|
|
49
|
-
status: ImageReport::STATUSES[:confirmed],
|
|
50
|
-
reviewed_by: current_user,
|
|
51
|
-
reviewed_at: Time.current
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
redirect_to admin_image_reports_path, notice: I18n.t("admin.image_reports.flash.report_confirmed")
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def dismiss
|
|
58
|
-
@report.update!(
|
|
59
|
-
status: ImageReport::STATUSES[:dismissed],
|
|
60
|
-
reviewed_by: current_user,
|
|
61
|
-
reviewed_at: Time.current
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
redirect_to admin_image_reports_path, notice: I18n.t("admin.image_reports.flash.report_dismissed")
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
private
|
|
68
|
-
|
|
69
|
-
def set_report
|
|
70
|
-
@report = ImageReport.find(params[:id])
|
|
71
|
-
rescue ActiveRecord::RecordNotFound
|
|
72
|
-
redirect_to admin_image_reports_path, alert: I18n.t("admin.image_reports.flash.report_not_found")
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def require_admin
|
|
76
|
-
return if current_user.admin?
|
|
77
|
-
|
|
78
|
-
redirect_to root_path, alert: I18n.t("admin.flash.admin_access_only")
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|