mirror of https://github.com/docusealco/docuseal
parent
279409ad41
commit
28429c1167
@ -1,19 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubmissionMailer < ApplicationMailer
|
||||
DEFAULT_MESSAGE = "You've been invited to submit documents."
|
||||
|
||||
def invitation_email(submission, message: DEFAULT_MESSAGE)
|
||||
@submission = submission
|
||||
@message = message
|
||||
|
||||
mail(to: @submission.email,
|
||||
subject: 'You have been invited to submit forms')
|
||||
end
|
||||
|
||||
def copy_to_submitter(submission)
|
||||
@submission = submission
|
||||
|
||||
mail(to: submission.email, subject: 'Here is your copy')
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubmitterMailer < ApplicationMailer
|
||||
DEFAULT_MESSAGE = "You've been invited to submit documents."
|
||||
|
||||
def invitation_email(submitter, message: DEFAULT_MESSAGE)
|
||||
@submitter = submitter
|
||||
@message = message
|
||||
|
||||
mail(to: @submitter.email,
|
||||
subject: 'You have been invited to submit forms')
|
||||
end
|
||||
|
||||
def copy_to_submitter(submitter)
|
||||
@submitter = submitter
|
||||
|
||||
mail(to: submitter.email, subject: 'Here is your copy')
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,55 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: submitters
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# completed_at :datetime
|
||||
# email :string not null
|
||||
# ip :string
|
||||
# opened_at :datetime
|
||||
# sent_at :datetime
|
||||
# slug :string not null
|
||||
# ua :string
|
||||
# uuid :string not null
|
||||
# values :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# submission_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_submitters_on_email (email)
|
||||
# index_submitters_on_slug (slug) UNIQUE
|
||||
# index_submitters_on_submission_id (submission_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (submission_id => submissions.id)
|
||||
#
|
||||
class Submitter < ApplicationRecord
|
||||
belongs_to :submission
|
||||
|
||||
attribute :values, :string, default: -> { {} }
|
||||
attribute :slug, :string, default: -> { SecureRandom.base58(8) }
|
||||
|
||||
serialize :values, JSON
|
||||
|
||||
has_one_attached :archive
|
||||
has_many_attached :documents
|
||||
|
||||
has_many_attached :attachments
|
||||
|
||||
def status
|
||||
if completed_at?
|
||||
'completed'
|
||||
elsif opened_at?
|
||||
'opened'
|
||||
elsif sent_at?
|
||||
'sent'
|
||||
else
|
||||
'awaiting'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,3 +0,0 @@
|
||||
<p>Hi</a>
|
||||
<%= @submission.values %>
|
||||
<%= link_to 'Download', submission_download_index_url(@submission.slug) %>
|
||||
@ -1,5 +1,5 @@
|
||||
<p>
|
||||
Form completed - thanks!
|
||||
</p>
|
||||
<%= button_to button_title(title: 'Send copy to Email', disabled_with: 'Sending'), send_submission_email_index_path, params: { submission_slug: @submission.slug }, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
<%= button_to button_title(title: 'Download documents', disabled_with: 'Downloading'), submission_download_index_path(@submission.slug), method: :get, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
<%= button_to button_title(title: 'Send copy to Email', disabled_with: 'Sending'), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
<%= button_to button_title(title: 'Download documents', disabled_with: 'Downloading'), submitter_download_index_path(@submitter.slug), method: :get, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
<p>Hi</a>
|
||||
<%= @submitter.values %>
|
||||
<%= link_to 'Download', submitter_download_index_url(@submitter.slug) %>
|
||||
@ -1,4 +1,4 @@
|
||||
<p>Hi there</p>
|
||||
<p>Hi there,</p>
|
||||
<p>You have been invited to submit a form:</p>
|
||||
<p><%= link_to 'Submit', submit_form_index_url(slug: @submission.slug) %></p>
|
||||
<p><%= link_to 'Submit', submit_form_url(slug: @submitter.slug) %></p>
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateSubmitters < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :submitters do |t|
|
||||
t.references :submission, null: false, foreign_key: true, index: true
|
||||
|
||||
t.string :uuid, null: false
|
||||
t.string :email, null: false, index: true
|
||||
t.string :slug, null: false, index: { unique: true }
|
||||
t.string :values, null: false
|
||||
t.string :ua
|
||||
t.string :ip
|
||||
|
||||
t.datetime :sent_at
|
||||
t.datetime :opened_at
|
||||
t.datetime :completed_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue