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

22 lines
419 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-05-18 00:54:41 +05:30
class Term < ApplicationRecord
2018-10-15 14:42:47 +05:30
include CacheMarkdownField
2018-11-08 19:23:39 +05:30
has_many :term_agreements
2018-10-15 14:42:47 +05:30
validates :terms, presence: true
cache_markdown_field :terms
def self.latest
order(:id).last
end
2018-11-08 19:23:39 +05:30
def accepted_by_user?(user)
user.accepted_term_id == id ||
term_agreements.accepted.where(user: user).exists?
end
2018-10-15 14:42:47 +05:30
end
end