Add terms of service (#33055)
This commit is contained in:
parent
7a2a345c08
commit
30aa0df88c
129 changed files with 1456 additions and 238 deletions
|
@ -57,6 +57,7 @@ class Admin::ActionLogFilter
|
|||
enable_relay: { target_type: 'Relay', action: 'enable' }.freeze,
|
||||
memorialize_account: { target_type: 'Account', action: 'memorialize' }.freeze,
|
||||
promote_user: { target_type: 'User', action: 'promote' }.freeze,
|
||||
publish_terms_of_service: { target_type: 'TermsOfService', action: 'publish' }.freeze,
|
||||
remove_avatar_user: { target_type: 'User', action: 'remove_avatar' }.freeze,
|
||||
reopen_report: { target_type: 'Report', action: 'reopen' }.freeze,
|
||||
resend_user: { target_type: 'User', action: 'resend' }.freeze,
|
||||
|
|
34
app/models/terms_of_service.rb
Normal file
34
app/models/terms_of_service.rb
Normal 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
|
25
app/models/terms_of_service/generator.rb
Normal file
25
app/models/terms_of_service/generator.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TermsOfService::Generator
|
||||
include ActiveModel::Model
|
||||
|
||||
TEMPLATE = Rails.root.join('config', 'templates', 'terms-of-service.md').read
|
||||
|
||||
VARIABLES = %i(
|
||||
admin_email
|
||||
arbitration_address
|
||||
arbitration_website
|
||||
dmca_address
|
||||
dmca_email
|
||||
domain
|
||||
jurisdiction
|
||||
).freeze
|
||||
|
||||
attr_accessor(*VARIABLES)
|
||||
|
||||
validates(*VARIABLES, presence: true)
|
||||
|
||||
def render
|
||||
format(TEMPLATE, VARIABLES.index_with { |key| public_send(key) })
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue