2014-09-24 14:45:35 -04:00
|
|
|
require_dependency 'site_text_type'
|
|
|
|
require_dependency 'site_text_class_methods'
|
2014-11-11 18:01:41 -05:00
|
|
|
require_dependency 'distributed_cache'
|
2014-09-24 14:45:35 -04:00
|
|
|
|
|
|
|
class SiteText < ActiveRecord::Base
|
2014-11-11 00:28:59 -05:00
|
|
|
|
2014-09-24 14:45:35 -04:00
|
|
|
extend SiteTextClassMethods
|
|
|
|
self.primary_key = 'text_type'
|
|
|
|
|
|
|
|
validates_presence_of :value
|
|
|
|
|
2014-11-11 00:28:59 -05:00
|
|
|
after_save do
|
2014-11-11 18:01:41 -05:00
|
|
|
SiteText.text_for_cache.clear
|
2014-12-22 21:15:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
after_destroy do
|
|
|
|
SiteText.text_for_cache.clear
|
2014-11-11 00:28:59 -05:00
|
|
|
end
|
|
|
|
|
2014-09-24 14:45:35 -04:00
|
|
|
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 :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
|
|
|
|
|
|
|
|
def site_text_type
|
|
|
|
@site_text_type ||= SiteText.find_text_type(text_type)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
2014-11-19 22:53:15 -05:00
|
|
|
# Table name: site_texts
|
2014-09-24 14:45:35 -04:00
|
|
|
#
|
2014-11-19 22:53:15 -05:00
|
|
|
# text_type :string(255) not null, primary key
|
|
|
|
# value :text not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
2014-09-24 14:45:35 -04:00
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
2014-11-19 22:53:15 -05:00
|
|
|
# index_site_texts_on_text_type (text_type) UNIQUE
|
2014-09-24 14:45:35 -04:00
|
|
|
#
|