rails-image-post-solution 0.1.8 → 0.1.13
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 +4 -4
- data/app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb +1 -1
- data/app/controllers/rails_image_post_solution/admin/image_reports_controller.rb +1 -1
- data/app/controllers/rails_image_post_solution/admin/users_controller.rb +1 -1
- data/app/controllers/rails_image_post_solution/admin.rb +7 -0
- data/app/controllers/rails_image_post_solution/application_controller.rb +8 -0
- data/app/controllers/rails_image_post_solution/image_reports_controller.rb +1 -1
- data/lib/rails_image_post_solution/engine.rb +30 -7
- data/lib/rails_image_post_solution/version.rb +1 -1
- metadata +3 -2
- data/app/controllers/rails_image_post_solution/admin/image_reports_controller.rb.bak +0 -81
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2ec235984ebcb48ca00c9de257a7c8270476ebf7b277eec2a6d2b5597442114
|
|
4
|
+
data.tar.gz: d6dad1b4c10d93752525f11c95fad77fe436aab80b8752e28d861a8c5658e753
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04356a80b8bc3dd7340a2a657430b16f1d1c70b56a0025e3af525f3333e35968b83a9497b7e0ea35917481dfe20e339b2eb4b3a5e098838e7e2f64d29193c99f
|
|
7
|
+
data.tar.gz: e93cd8685eefed70b6445911ae27ec266ac78567b502a5e96120cb94c63b95127d4bbf98f4ba04047e14e22ebe84cec64605dd9671df956c7d771cdb60daebf7
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module RailsImagePostSolution
|
|
4
4
|
module Admin
|
|
5
|
-
class ImageReportsController < ApplicationController
|
|
5
|
+
class ImageReportsController < RailsImagePostSolution::ApplicationController
|
|
6
6
|
before_action :require_login
|
|
7
7
|
before_action :require_admin
|
|
8
8
|
before_action :set_report, only: %i[show confirm dismiss]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module RailsImagePostSolution
|
|
4
4
|
module Admin
|
|
5
|
-
class UsersController < ApplicationController
|
|
5
|
+
class UsersController < RailsImagePostSolution::ApplicationController
|
|
6
6
|
before_action :require_login
|
|
7
7
|
before_action :require_admin
|
|
8
8
|
before_action :set_user, only: %i[show suspend unsuspend ban unban]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsImagePostSolution
|
|
4
|
+
class ApplicationController < ::ApplicationController
|
|
5
|
+
# Engine's base controller inherits from host application's ApplicationController
|
|
6
|
+
# This allows the engine to use the host app's authentication methods
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module RailsImagePostSolution
|
|
4
|
-
class ImageReportsController < ApplicationController
|
|
4
|
+
class ImageReportsController < RailsImagePostSolution::ApplicationController
|
|
5
5
|
before_action :require_login
|
|
6
6
|
before_action :set_attachment, only: :create
|
|
7
7
|
|
|
@@ -9,6 +9,29 @@ module RailsImagePostSolution
|
|
|
9
9
|
# Explicitly set engine root
|
|
10
10
|
config.root = File.expand_path('../..', __dir__)
|
|
11
11
|
|
|
12
|
+
# Eager load engine classes to ensure they're available
|
|
13
|
+
config.eager_load_paths += %W[
|
|
14
|
+
#{root}/app/controllers
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
# Load admin module and controllers when app prepares
|
|
18
|
+
config.to_prepare do
|
|
19
|
+
# Ensure Admin module is loaded
|
|
20
|
+
unless defined?(RailsImagePostSolution::Admin)
|
|
21
|
+
require Engine.root.join('app/controllers/rails_image_post_solution/admin.rb')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Ensure ApplicationController is loaded
|
|
25
|
+
unless defined?(RailsImagePostSolution::ApplicationController)
|
|
26
|
+
require Engine.root.join('app/controllers/rails_image_post_solution/application_controller.rb')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Eager load all admin controllers
|
|
30
|
+
Dir[Engine.root.join('app/controllers/rails_image_post_solution/admin/**/*_controller.rb')].each do |file|
|
|
31
|
+
require file
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
12
35
|
# Load routes when engine is initialized
|
|
13
36
|
config.after_initialize do
|
|
14
37
|
routes_path = RailsImagePostSolution::Engine.root.join("config", "routes.rb")
|
|
@@ -17,14 +40,14 @@ module RailsImagePostSolution
|
|
|
17
40
|
load routes_path
|
|
18
41
|
end
|
|
19
42
|
|
|
20
|
-
# After routes are loaded, make helpers available
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
# After routes are loaded, make helpers available directly
|
|
44
|
+
Rails.application.config.to_prepare do
|
|
45
|
+
# Include in all controllers
|
|
46
|
+
ActionController::Base.include RailsImagePostSolution::Engine.routes.url_helpers
|
|
47
|
+
ActionController::Base.helper RailsImagePostSolution::Engine.routes.url_helpers
|
|
25
48
|
|
|
26
|
-
|
|
27
|
-
include RailsImagePostSolution::Engine.routes.url_helpers
|
|
49
|
+
# Include in all views
|
|
50
|
+
ActionView::Base.include RailsImagePostSolution::Engine.routes.url_helpers
|
|
28
51
|
end
|
|
29
52
|
end
|
|
30
53
|
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.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dhq_boiler
|
|
@@ -93,10 +93,11 @@ 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
|
+
- app/controllers/rails_image_post_solution/application_controller.rb
|
|
100
101
|
- app/controllers/rails_image_post_solution/image_reports_controller.rb
|
|
101
102
|
- app/jobs/rails_image_post_solution/image_moderation_job.rb
|
|
102
103
|
- app/models/rails_image_post_solution/image_report.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
|