Skip to content

Commit

Permalink
Updates receipt email to handle abstracts better
Browse files Browse the repository at this point in the history
** Why are these changes being introduced:

* Currently, users whose abstracts have line breaks / carriage returns
  are seeing them stripped out in the receipt email which they receive.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/etd-380

** How does this address that need:

* This renders the abstract field using the simple_format() function,
  which replaces carriage return characters \n and \r\n with <br> and
  <p> tags. This improves their rendering in the email template.

** Document any side effects to this change:

* The block of fields in the email template is now wrapped in a div tag
  rather than a p tag (to prevent nested p tags).
* Additionally, the receipt email now visually separates the abstract
  field from the rest of the submitted fields. I think this is fine,
  but have asked the project team on Slack to confirm (we can follow
  up in QA testing).
  • Loading branch information
matt-bernhardt committed Aug 27, 2021
1 parent 690cada commit 843ec96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions app/views/receipt_mailer/receipt_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The information we have on record is listed below.</p>
<strong>ORCID iD:</strong> <%= @user.orcid %><br>
</p>

<p style="margin-left: 40px;">
<div style="margin-left: 40px;">
<strong>Thesis title:</strong> <%= @thesis.title %><br>
<strong>Name as it appears on your thesis:</strong> <%= @user.preferred_name %><br>
<strong>Co-author:</strong> <%= @thesis.coauthors %><br>
Expand All @@ -34,9 +34,10 @@ The information we have on record is listed below.</p>
<strong>Copyright holder:</strong> <%= @thesis.copyright.holder %><br>
<strong>License:</strong> <%= @thesis.license_id? ? @thesis.license.display_description : "" %><br>
<strong>Thesis supervisors:</strong> <%= @thesis.advisors.map { |a| a.name }.join('; ') %><br>
<strong>Abstract:</strong> <%= @thesis.abstract %><br>
<strong>Abstract:</strong><br>
<%= simple_format(@thesis.abstract, {}, wrapper_tag: "p") %>
<strong>Notes:</strong> <%= @thesis.author_note %><br>
</p>
</div>

<p>Let us know if you have any questions. And again, congratulations
on finishing (or almost finishing) your degree!</p>
Expand Down
7 changes: 4 additions & 3 deletions test/fixtures/receipt_mailer/receipt_email
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The information we have on record is listed below.</p>
<strong>ORCID iD:</strong> <br>
</p>

<p style="margin-left: 40px;">
<div style="margin-left: 40px;">
<strong>Thesis title:</strong> MyString<br>
<strong>Name as it appears on your thesis:</strong> Robot, Admin<br>
<strong>Co-author:</strong> My co-author<br>
Expand All @@ -44,9 +44,10 @@ The information we have on record is listed below.</p>
<strong>Copyright holder:</strong> MIT<br>
<strong>License:</strong> No Creative Commons License<br>
<strong>Thesis supervisors:</strong> Addy McAdvisor<br>
<strong>Abstract:</strong> MyText<br>
<strong>Abstract:</strong><br>
<p>MyText</p>
<strong>Notes:</strong> <br>
</p>
</div>

<p>Let us know if you have any questions. And again, congratulations
on finishing (or almost finishing) your degree!</p>
Expand Down

0 comments on commit 843ec96

Please sign in to comment.