2013-04-04 12:59:44 -04:00
|
|
|
require_dependency 'site_content_type'
|
|
|
|
require_dependency 'site_content_class_methods'
|
|
|
|
|
|
|
|
class SiteContent < ActiveRecord::Base
|
|
|
|
extend SiteContentClassMethods
|
|
|
|
|
2013-04-05 13:59:00 -04:00
|
|
|
self.primary_key = 'content_type'
|
|
|
|
|
2013-04-04 12:59:44 -04:00
|
|
|
validates_presence_of :content
|
|
|
|
|
|
|
|
def self.formats
|
|
|
|
@formats ||= Enum.new(:plain, :markdown, :html, :css)
|
|
|
|
end
|
|
|
|
|
2013-04-05 15:21:55 -04:00
|
|
|
add_content_type :usage_tips, default_18n_key: 'system_messages.usage_tips.text_body_template'
|
|
|
|
add_content_type :education_new_topic, default_18n_key: 'education.new-topic'
|
|
|
|
add_content_type :education_new_reply, default_18n_key: 'education.new-reply'
|
|
|
|
add_content_type :tos_user_content_license, default_18n_key: 'terms_of_service.user_content_license'
|
|
|
|
add_content_type :tos_miscellaneous, default_18n_key: 'terms_of_service.miscellaneous'
|
2013-06-04 21:53:36 -04:00
|
|
|
add_content_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
|
2014-02-07 16:04:00 -05:00
|
|
|
add_content_type :tos_signup_form_message, default_18n_key: 'terms_of_service.signup_form_message', format: :html
|
2014-01-02 10:22:04 -05:00
|
|
|
add_content_type :top, allow_blank: true, format: :html
|
|
|
|
add_content_type :bottom, allow_blank: true, format: :html
|
|
|
|
add_content_type :head, allow_blank: true, format: :html
|
2014-05-12 16:51:53 -04:00
|
|
|
add_content_type :notification_email_top, allow_blank: true, format: :markdown
|
2013-11-14 10:41:16 -05:00
|
|
|
|
2013-04-04 12:59:44 -04:00
|
|
|
def site_content_type
|
|
|
|
@site_content_type ||= SiteContent.content_types.find {|t| t.content_type == content_type.to_sym}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2013-05-23 22:48:32 -04:00
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: site_contents
|
|
|
|
#
|
|
|
|
# content_type :string(255) not null, primary key
|
|
|
|
# content :text not null
|
2014-05-27 21:49:50 -04:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2013-05-23 22:48:32 -04:00
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_site_contents_on_content_type (content_type) UNIQUE
|
|
|
|
#
|