2023-02-08 14:21:39 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class FormTemplate < ActiveRecord::Base
|
2023-06-28 15:49:19 -04:00
|
|
|
validates :name,
|
|
|
|
presence: true,
|
|
|
|
uniqueness: true,
|
|
|
|
length: {
|
2024-09-10 11:11:44 -04:00
|
|
|
maximum: -> { SiteSetting.max_form_template_title_length },
|
2023-06-28 15:49:19 -04:00
|
|
|
}
|
|
|
|
validates :template,
|
|
|
|
presence: true,
|
|
|
|
length: {
|
2024-09-10 11:11:44 -04:00
|
|
|
maximum: -> { SiteSetting.max_form_template_content_length },
|
2023-06-28 15:49:19 -04:00
|
|
|
}
|
2024-09-10 11:11:44 -04:00
|
|
|
validates_with FormTemplateYamlValidator, if: ->(ft) { ft.template }
|
2023-02-23 14:18:14 -05:00
|
|
|
|
|
|
|
has_many :category_form_templates, dependent: :destroy
|
|
|
|
has_many :categories, through: :category_form_templates
|
2023-08-29 17:41:33 -04:00
|
|
|
|
|
|
|
class NotAllowed < StandardError
|
|
|
|
end
|
2023-02-08 14:21:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: form_templates
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
2024-09-10 11:11:44 -04:00
|
|
|
# name :string not null
|
2023-02-08 14:21:39 -05:00
|
|
|
# template :text not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_form_templates_on_name (name) UNIQUE
|
|
|
|
#
|