mirror of https://github.com/docusealco/docuseal
parent
43b32d05cb
commit
d53fa5613b
@ -1,19 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubmitterMailer < ApplicationMailer
|
||||
DEFAULT_MESSAGE = "You've been invited to submit the following documents:"
|
||||
DEFAULT_MESSAGE = %(You have been invited to submit the "%<name>s" form:)
|
||||
|
||||
def invitation_email(submitter, message: DEFAULT_MESSAGE)
|
||||
def invitation_email(submitter, message: format(DEFAULT_MESSAGE, name: submitter.submission.template.name))
|
||||
@submitter = submitter
|
||||
@message = message
|
||||
|
||||
mail(to: @submitter.email,
|
||||
subject: 'You have been invited to submit forms')
|
||||
subject: 'You have been invited to submit a form')
|
||||
end
|
||||
|
||||
def copy_to_submitter(submitter)
|
||||
def completed_email(submitter, user)
|
||||
@submitter = submitter
|
||||
@user = user
|
||||
|
||||
mail(to: submitter.email, subject: 'Here is your copy')
|
||||
mail(to: user.email,
|
||||
subject: %(#{submitter.email} has completed the "#{submitter.submission.template.name}" form))
|
||||
end
|
||||
|
||||
def documents_copy_email(submitter)
|
||||
@submitter = submitter
|
||||
@documents = Submitters.select_attachments_for_download(submitter)
|
||||
|
||||
@documents.each do |attachment|
|
||||
attachments[attachment.filename.to_s] = attachment.download
|
||||
end
|
||||
|
||||
mail(to: submitter.email, subject: 'Your copy of documents')
|
||||
end
|
||||
end
|
||||
|
||||
|
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 412 B |
@ -1 +0,0 @@
|
||||
<%= yield %>
|
||||
@ -0,0 +1,4 @@
|
||||
<div class="text-center px-2">
|
||||
Powered by
|
||||
<a href="<%= Docuseal::PRODUCT_URL %>" class="underline"><%= Docuseal::PRODUCT_NAME %></a> - open source documents software
|
||||
</div>
|
||||
@ -0,0 +1,3 @@
|
||||
<p>Hi <%= @user.first_name %>,</p>
|
||||
<p><%= @submitter.email %> has completed the "<%= @submitter.submission.template.name %>" form.</p>
|
||||
<p><%= link_to 'View Submission', submission_url(@submitter.submission) %></p>
|
||||
@ -1,3 +0,0 @@
|
||||
<p>Hi</a>
|
||||
<%= @submitter.values %>
|
||||
<%= link_to 'Download', submitter_download_index_url(@submitter.slug) %>
|
||||
@ -0,0 +1,13 @@
|
||||
<p>Hi there,</p>
|
||||
<p>Please check the copy of your "<%= @submitter.submission.template.name %>" submission in the email attachments.</p>
|
||||
<p>Alternatively, you can download the copy using:</p>
|
||||
<% @documents.each do |document| %>
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to document.filename.to_s, rails_blob_url(document) %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<p>
|
||||
Thanks,<br><%= @submitter.submission.template.account.name %>
|
||||
</p>
|
||||
@ -1,4 +1,7 @@
|
||||
<p>Hi there,</p>
|
||||
<p>You have been invited to submit a form:</p>
|
||||
<p><%= link_to 'Submit', submit_form_url(slug: @submitter.slug) %></p>
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<%= simple_format(@message) %>
|
||||
<p><%= link_to 'Submit Form', submit_form_url(slug: @submitter.slug) %></p>
|
||||
<p>Please contact us by replying to this email if you didn't request this.</p>
|
||||
<p>
|
||||
Thanks,<br><%= @submitter.submission.template.account.name %>
|
||||
</p>
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
<p>Hello <%= @user.first_name %>,</p>
|
||||
<p>You have been invited to Docuseal. You can sign up this through the link below.</p>
|
||||
<p><%= link_to 'Set my password', invitation_url(reset_password_token: @token) %></p>
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>You have been invited to <%= @user.account.name %> DocuSeal. Please sign up using the link below:</p>
|
||||
<p><%= link_to 'Sign up', invitation_url(reset_password_token: @token) %></p>
|
||||
<p>Please contact us by replying to this email if you didn't request this.</p>
|
||||
<p>
|
||||
Thanks,<br><%= @user.account.name %>
|
||||
</p>
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Submitters
|
||||
module_function
|
||||
|
||||
def select_attachments_for_download(submitter)
|
||||
original_documents = submitter.submission.template.documents.preload(:blob)
|
||||
is_more_than_two_images = original_documents.count(&:image?) > 1
|
||||
|
||||
submitter.documents.preload(:blob).reject do |attachment|
|
||||
is_more_than_two_images && original_documents.find { |a| a.uuid == attachment.uuid }&.image?
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,2 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
Allow: /
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubmitterMailerPreview < ActionMailer::Preview
|
||||
def invitation_email
|
||||
SubmitterMailer.invitation_email(Submitter.last)
|
||||
end
|
||||
|
||||
def completed_email
|
||||
submitter = Submitter.where.not(completed_at: nil).joins(:documents_attachments).last
|
||||
|
||||
SubmitterMailer.completed_email(submitter, User.last)
|
||||
end
|
||||
|
||||
def documents_copy_email
|
||||
submitter = Submitter.where.not(completed_at: nil).joins(:documents_attachments).last
|
||||
|
||||
SubmitterMailer.documents_copy_email(submitter)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue