discourse/app/models/site_text.rb

45 lines
1.6 KiB
Ruby
Raw Normal View History

2014-09-25 02:45:35 +08:00
require_dependency 'site_text_type'
require_dependency 'site_text_class_methods'
class SiteText < ActiveRecord::Base
extend SiteTextClassMethods
self.primary_key = 'text_type'
validates_presence_of :value
def self.formats
@formats ||= Enum.new(:plain, :markdown, :html, :css)
end
add_text_type :usage_tips, default_18n_key: 'system_messages.usage_tips.text_body_template'
add_text_type :education_new_topic, default_18n_key: 'education.new-topic'
add_text_type :education_new_reply, default_18n_key: 'education.new-reply'
add_text_type :tos_user_content_license, default_18n_key: 'terms_of_service.user_content_license'
add_text_type :tos_miscellaneous, default_18n_key: 'terms_of_service.miscellaneous'
add_text_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
add_text_type :tos_signup_form_message, default_18n_key: 'terms_of_service.signup_form_message', format: :html
add_text_type :top, allow_blank: true, format: :html
add_text_type :bottom, allow_blank: true, format: :html
add_text_type :head, allow_blank: true, format: :html
add_text_type :notification_email_top, allow_blank: true, format: :markdown
def site_text_type
@site_text_type ||= SiteText.find_text_type(text_type)
end
end
# == Schema Information
#
# Table name: site_text
#
# text_type :string(255) not null, primary key
# value :text not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_site_text_on_text_type (text_type) UNIQUE
#