* Enable Rails cops * Fix Rails/DynamicFindBy * Fix Rails/HttpStatus * Fix Rails/Blank * Fix Rails/RequestReferer * Fix Rails/ActiveRecordAliases * Fix Rails/FindBy * Fix Rails/Presence * Fix Rails/Delegate * Fix Rails/Validation * Fix Rails/PluralizationGrammar * Fix Rails/Present * Fix Rails/Output * Fix Rails/Blank * Fix Rails/FilePath * Fix Rails/InverseOf * Fix Rails/LexicallyScopedActionFilter * Add Rails/OutputSafety to TODO * Add Rails/HasManyOrHasOneDependent to TODO * Add Rails/SkipsModelValidations to TODO
26 lines
1.1 KiB
Ruby
26 lines
1.1 KiB
Ruby
class FeedbackMessage < ApplicationRecord
|
|
belongs_to :offender, foreign_key: "offender_id", class_name: "User", optional: true, inverse_of: :feedback_messages
|
|
belongs_to :reviewer, foreign_key: "reviewer_id", class_name: "User", optional: true, inverse_of: :feedback_messages
|
|
belongs_to :reporter, foreign_key: "reporter_id", class_name: "User", optional: true, inverse_of: :feedback_messages
|
|
belongs_to :affected, foreign_key: "affected_id", class_name: "User", optional: true, inverse_of: :feedback_messages
|
|
has_many :notes, as: :noteable, inverse_of: :noteable, dependent: :destroy
|
|
|
|
validates :feedback_type, :message, presence: true
|
|
validates :reported_url, :category, presence: { if: :abuse_report? }
|
|
validates :category,
|
|
inclusion: {
|
|
in: ["spam", "other", "rude or vulgar", "harassment", "bug"]
|
|
}
|
|
validates :status,
|
|
inclusion: {
|
|
in: %w[Open Invalid Resolved]
|
|
}
|
|
|
|
def abuse_report?
|
|
feedback_type == "abuse-reports"
|
|
end
|
|
|
|
def capitalize_status
|
|
self.status = status.capitalize if status.present?
|
|
end
|
|
end
|