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