diff options
Diffstat (limited to 'app/models/application_setting/term.rb')
-rw-r--r-- | app/models/application_setting/term.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/application_setting/term.rb b/app/models/application_setting/term.rb new file mode 100644 index 00000000000..3b1dfe7e4ef --- /dev/null +++ b/app/models/application_setting/term.rb @@ -0,0 +1,19 @@ +class ApplicationSetting + class Term < ActiveRecord::Base + include CacheMarkdownField + has_many :term_agreements + + validates :terms, presence: true + + cache_markdown_field :terms + + def self.latest + order(:id).last + end + + def accepted_by_user?(user) + user.accepted_term_id == id || + term_agreements.accepted.where(user: user).exists? + end + end +end |