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: 658c71c39ad56304e65bd91b5836c22b9a62c0c6850f928c90d38c7e59befc95
4
- data.tar.gz: 6adc604cb0b0a31fcca15a32949dd0e1abc5db22fda7fa4a7bf3136d086c155c
3
+ metadata.gz: 8cff46842aaf17f3755a392ae1b340330bb15b54c94616db8ed96c646efcc468
4
+ data.tar.gz: c55be48295ec1c5366440b924b1101428f851d1fa913018eaed1bce968a434d6
5
5
  SHA512:
6
- metadata.gz: 7f3d08bf7970740fb04fc4bef3633c88e9e66f15cd7c48b9b7970792fcf59dab2124b4b2e56209c6a0dc38062315f71e0c5c4026e12382fa8f21d253d1e9017a
7
- data.tar.gz: 67dc5bab3ebd8704884fe3e3008284c54153db07e282e038b5e5d581b6e5249f83121029590116e74b99d69ddd0a9d7d8b21eed01e26454cb782574c1fb2d6b0
6
+ metadata.gz: 6b8f5fa256f33c94892be69b3c5aeed7b14cfd1be7a1451f79f8c574b5b53f0819acdf1a42b719be9dd24b591228c82eaaa016ad82e0d8e1def6ad94b9c37a97
7
+ data.tar.gz: c6843b246611dcb5db6445dad0e8d33b0acaad626140dd4b8445dda7db3fda1989b44f0c6305c987c707d9c95344195783a6353573ba67b3903f89c20bbeb805
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsImagePostSolution
4
+ module Admin
5
+ # Admin controllers namespace
6
+ end
7
+ end
@@ -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
- ActiveSupport.on_load(:action_controller_base) do
22
- include RailsImagePostSolution::Engine.routes.url_helpers
23
- helper RailsImagePostSolution::Engine.routes.url_helpers
24
- end
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
- ActiveSupport.on_load(:action_view) do
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsImagePostSolution
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.10"
5
5
  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.8
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