2018-08-03 03:15:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-24 05:37:41 -04:00
|
|
|
class ApplicationSetting
|
|
|
|
class Term < ActiveRecord::Base
|
2018-04-24 12:28:04 -04:00
|
|
|
include CacheMarkdownField
|
2018-05-25 19:17:57 -04:00
|
|
|
has_many :term_agreements
|
2018-04-24 12:28:04 -04:00
|
|
|
|
2018-04-24 05:37:41 -04:00
|
|
|
validates :terms, presence: true
|
2018-04-24 12:28:04 -04:00
|
|
|
|
|
|
|
cache_markdown_field :terms
|
|
|
|
|
|
|
|
def self.latest
|
|
|
|
order(:id).last
|
|
|
|
end
|
2018-05-25 19:17:57 -04:00
|
|
|
|
|
|
|
def accepted_by_user?(user)
|
|
|
|
user.accepted_term_id == id ||
|
|
|
|
term_agreements.accepted.where(user: user).exists?
|
|
|
|
end
|
2018-04-24 05:37:41 -04:00
|
|
|
end
|
|
|
|
end
|