debian-mirror-gitlab/app/models/application_setting/term.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
460 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
class ApplicationSetting
2019-07-07 11:18:12 +05:30
class Term < ApplicationRecord
2018-10-15 14:42:47 +05:30
include CacheMarkdownField
2021-09-30 23:02:18 +05:30
has_many :term_agreements
2018-10-15 14:42:47 +05:30
cache_markdown_field :terms
2021-09-30 23:02:18 +05:30
validates :terms, presence: true
2018-10-15 14:42:47 +05:30
def self.latest
order(:id).last
end
2018-11-08 19:23:39 +05:30
def accepted_by_user?(user)
2021-01-03 14:25:43 +05:30
return true if user.project_bot?
2018-11-08 19:23:39 +05:30
user.accepted_term_id == id ||
term_agreements.accepted.where(user: user).exists?
end
2018-10-15 14:42:47 +05:30
end
end