one-off submission

This commit is contained in:
Pete Matsyburka
2025-05-31 15:15:25 +03:00
committed by Pete Matsyburka
parent c59d948d41
commit f03166b4ea
47 changed files with 218 additions and 145 deletions
+2 -2
View File
@@ -13,7 +13,7 @@
# account_id :bigint not null
# submission_id :bigint not null
# submitter_id :bigint not null
# template_id :bigint not null
# template_id :bigint
#
# Indexes
#
@@ -24,7 +24,7 @@ class CompletedSubmitter < ApplicationRecord
belongs_to :submitter
belongs_to :submission
belongs_to :account
belongs_to :template
belongs_to :template, optional: true
has_many :completed_documents, dependent: :destroy,
primary_key: :submitter_id,
+12 -2
View File
@@ -7,6 +7,7 @@
# id :bigint not null, primary key
# archived_at :datetime
# expire_at :datetime
# name :text
# preferences :text not null
# slug :string not null
# source :text not null
@@ -18,7 +19,7 @@
# updated_at :datetime not null
# account_id :bigint not null
# created_by_user_id :bigint
# template_id :bigint not null
# template_id :bigint
#
# Indexes
#
@@ -33,7 +34,7 @@
# fk_rails_... (template_id => templates.id)
#
class Submission < ApplicationRecord
belongs_to :template
belongs_to :template, optional: true
belongs_to :account
belongs_to :created_by_user, class_name: 'User', optional: true
@@ -56,6 +57,7 @@ class Submission < ApplicationRecord
has_one_attached :combined_document
has_many_attached :preview_documents
has_many_attached :documents
has_many :template_accesses, primary_key: :template_id, foreign_key: :template_id, dependent: nil, inverse_of: false
@@ -96,6 +98,14 @@ class Submission < ApplicationRecord
expire_at && expire_at <= Time.current
end
def schema_documents
if template_id?
template_schema_documents
else
documents_attachments
end
end
def fields_uuid_index
@fields_uuid_index ||= (template_fields || template.fields).index_by { |f| f['uuid'] }
end