1
0
Fork 0
forked from gitea/nas

Add terms of service (#33055)

This commit is contained in:
Eugen Rochko 2024-12-09 11:04:46 +01:00 committed by GitHub
parent 7a2a345c08
commit 30aa0df88c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
129 changed files with 1456 additions and 238 deletions

View file

@ -0,0 +1,34 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: terms_of_services
#
# id :bigint(8) not null, primary key
# changelog :text default(""), not null
# notification_sent_at :datetime
# published_at :datetime
# text :text default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
class TermsOfService < ApplicationRecord
scope :published, -> { where.not(published_at: nil).order(published_at: :desc) }
scope :live, -> { published.limit(1) }
scope :draft, -> { where(published_at: nil).order(id: :desc).limit(1) }
validates :text, presence: true
validates :changelog, presence: true, if: -> { published? }
def published?
published_at.present?
end
def notification_sent?
notification_sent_at.present?
end
def scope_for_notification
User.confirmed.joins(:account).merge(Account.without_suspended).where(created_at: (..published_at))
end
end