Class: RailsImagePostSolution::ImageReport
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- RailsImagePostSolution::ImageReport
- Defined in:
- app/models/rails_image_post_solution/image_report.rb
Constant Summary collapse
- STATUSES =
Status constants
{ pending: "pending", # Not reviewed yet reviewed: "reviewed", # Reviewed (no action needed) confirmed: "confirmed", # Confirmed (flagged as inappropriate) dismissed: "dismissed" # Dismissed (no issues found) }.freeze
- REASON_CATEGORIES =
Report reason category keys (translations via I18n.t(“rails_image_post_solution.image_report.categories.#key”))
%i[r18 r18g copyright spam harassment other].freeze
Class Method Summary collapse
-
.categories_for_select ⇒ Object
Get category list (for use in views).
-
.category_text(key) ⇒ Object
Get category translation text.
-
.image_reported?(attachment_id) ⇒ Boolean
Check if image has been reported as inappropriate.
-
.report_count(attachment_id) ⇒ Object
Get report count for image.
Class Method Details
.categories_for_select ⇒ Object
Get category list (for use in views)
24 25 26 |
# File 'app/models/rails_image_post_solution/image_report.rb', line 24 def self.categories_for_select REASON_CATEGORIES.map { |key| [ key, category_text(key) ] } end |
.category_text(key) ⇒ Object
Get category translation text
19 20 21 |
# File 'app/models/rails_image_post_solution/image_report.rb', line 19 def self.category_text(key) I18n.t("rails_image_post_solution.image_report.categories.#{key}") end |
.image_reported?(attachment_id) ⇒ Boolean
Check if image has been reported as inappropriate
46 47 48 49 50 |
# File 'app/models/rails_image_post_solution/image_report.rb', line 46 def self.image_reported?() where(active_storage_attachment_id: ) .where(status: [ STATUSES[:pending], STATUSES[:confirmed] ]) .exists? end |
.report_count(attachment_id) ⇒ Object
Get report count for image
53 54 55 |
# File 'app/models/rails_image_post_solution/image_report.rb', line 53 def self.report_count() where(active_storage_attachment_id: ).count end |