2018-08-03 03:15:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-24 05:37:41 -04:00
|
|
|
class ApplicationSetting
|
2019-03-28 09:17:42 -04:00
|
|
|
class Term < ApplicationRecord
|
2018-04-24 12:28:04 -04:00
|
|
|
include CacheMarkdownField
|
|
|
|
|
2021-07-11 23:09:27 -04:00
|
|
|
has_many :term_agreements
|
2018-04-24 12:28:04 -04:00
|
|
|
|
|
|
|
cache_markdown_field :terms
|
|
|
|
|
2021-07-21 17:10:10 -04:00
|
|
|
validates :terms, presence: true
|
2021-07-11 23:09:27 -04:00
|
|
|
|
2018-04-24 12:28:04 -04:00
|
|
|
def self.latest
|
|
|
|
order(:id).last
|
|
|
|
end
|
2018-05-25 19:17:57 -04:00
|
|
|
|
|
|
|
def accepted_by_user?(user)
|
2020-10-01 02:09:59 -04:00
|
|
|
return true if user.project_bot?
|
|
|
|
|
2018-05-25 19:17:57 -04:00
|
|
|
user.accepted_term_id == id ||
|
|
|
|
term_agreements.accepted.where(user: user).exists?
|
|
|
|
end
|
2018-04-24 05:37:41 -04:00
|
|
|
end
|
|
|
|
end
|