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