Files
docuseal/app/models/submission.rb
T

50 lines
1.3 KiB
Ruby
Raw Normal View History

2023-05-21 17:59:36 +03:00
# frozen_string_literal: true
# == Schema Information
#
# Table name: submissions
#
2023-07-26 09:58:50 +03:00
# id :bigint not null, primary key
# deleted_at :datetime
2023-08-05 19:20:06 +03:00
# source :text not null
2023-07-26 09:58:50 +03:00
# template_fields :text
# template_schema :text
# template_submitters :text
# created_at :datetime not null
# updated_at :datetime not null
# created_by_user_id :bigint
# template_id :bigint not null
2023-05-21 17:59:36 +03:00
#
# Indexes
#
2023-06-29 02:04:17 +03:00
# index_submissions_on_created_by_user_id (created_by_user_id)
# index_submissions_on_template_id (template_id)
2023-05-21 17:59:36 +03:00
#
# Foreign Keys
#
2023-06-29 02:04:17 +03:00
# fk_rails_... (created_by_user_id => users.id)
2023-05-31 23:19:20 +03:00
# fk_rails_... (template_id => templates.id)
2023-05-21 17:59:36 +03:00
#
class Submission < ApplicationRecord
2023-05-31 23:19:20 +03:00
belongs_to :template
2023-08-05 15:25:16 +03:00
has_one :account, through: :template
2023-06-29 02:04:17 +03:00
belongs_to :created_by_user, class_name: 'User', optional: true
2023-05-21 17:59:36 +03:00
2023-06-13 00:29:07 +03:00
has_many :submitters, dependent: :destroy
2023-05-21 17:59:36 +03:00
2023-07-26 09:58:50 +03:00
serialize :template_fields, JSON
serialize :template_schema, JSON
serialize :template_submitters, JSON
2023-08-05 19:20:06 +03:00
attribute :source, :string, default: 'link'
2023-05-21 17:59:36 +03:00
scope :active, -> { where(deleted_at: nil) }
2023-08-05 19:20:06 +03:00
enum :source, {
invite: 'invite',
api: 'api',
embed: 'embed',
link: 'link'
}, scope: false, prefix: true
2023-05-21 17:59:36 +03:00
end