discourse/app/models/admin_notice.rb
Ted Johansson 3137e60653
DEV: Database backed admin notices ()
This PR introduces a basic AdminNotice model to store these notices. Admin notices are categorized by their source/type (currently only notices from problem check.) They also have a priority.
2024-05-23 09:29:08 +08:00

34 lines
814 B
Ruby

# frozen_string_literal: true
class AdminNotice < ActiveRecord::Base
validates :identifier, presence: true
enum :priority, %i[low high].freeze
enum :subject, %i[problem].freeze
def message
I18n.t(
"dashboard.#{subject}.#{identifier}",
**details.symbolize_keys.merge(base_path: Discourse.base_path),
)
end
end
# == Schema Information
#
# Table name: admin_notices
#
# id :bigint not null, primary key
# subject :integer not null
# priority :integer not null
# identifier :string not null
# details :json not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_admin_notices_on_subject (subject)
# index_admin_notices_on_identifier (identifier)
#