Skip to content

Commit

Permalink
Merge pull request #1479 from ScilifelabDataCentre/DDS-1338-Improve-o…
Browse files Browse the repository at this point in the history
…n-email-layout

New email layout when project is released
  • Loading branch information
rv0lt authored Oct 10, 2023
2 parents fe4d13d + fdca870 commit e9a0d1d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 20 deletions.
1 change: 1 addition & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,4 @@ _Nothing merged in CLI during this sprint_
- Project title displayed along with the internal project ID email sent when a project is released ([#1475](https://github.com/ScilifelabDataCentre/dds_web/pull/1475))
- Use full DDS name in MOTD email subject ([#1477](https://github.com/ScilifelabDataCentre/dds_web/pull/1477))
- Add flag --verify-checksum to the comand in email template ([#1478])(https://github.com/ScilifelabDataCentre/dds_web/pull/1478)
- Improved email layout; Highlighted information and commands when project is released ([#1479])(https://github.com/ScilifelabDataCentre/dds_web/pull/1479)
23 changes: 22 additions & 1 deletion dds_web/templates/mail/mail_base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
<!doctype html>
<html>

<script>
function copyTextProjectRelease(copyOption) {
// Get the text field
let copyText;
if (copyOption == 1){
copyText = document.getElementById("ProjectListing").innerHTML;
}
else if (copyOption == 2){
copyText = document.getElementById("ProjectDownload").innerHTML;
}
// Copy the text inside the text field
navigator.clipboard.writeText(copyText);

// Alert the copied text
alert("Copied the text: " + copyText);
}
</script>

<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Expand Down Expand Up @@ -122,6 +139,10 @@
border-color: #a00202 !important;
}
}
code {
background-color: pink;
color: black;
}
</style>
</head>

Expand Down
29 changes: 18 additions & 11 deletions dds_web/templates/mail/project_release.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,29 @@
</ul>
</p>
<p style="font-family: arial, sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">
You were added to this project {% if unit_email %} on behalf of {% else %} by {% endif %} {{displayed_sender}}.
</p>
<p style="font-family: arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; Margin-top: 0px;">
To list the files in this project, run: <br>
<code id="ProjectListing">dds ls -p {{project_id}}</code> <button onclick="copyTextProjectRelease(1)" style="font-size: 12px; font-weight: normal;">Copy command</button></p>
<br>
<p style="font-family: arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; Margin-top: 0px;">
To download all the files in this project to your current directory, run: <br>
<code id="ProjectDownload">dds data get -p {{project_id}} -a --verify-checksum</code> <button onclick="copyTextProjectRelease(2)" style="font-size: 12px; font-weight: normal;">Copy command</button> </p>
<p style="font-family: arial, sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-top: 15px;">
For more information (including an installation guide), see the DDS CLI documentation here: <a href="https://scilifelabdatacentre.github.io/dds_cli/">scilifelabdatacentre.github.io/dds_cli</a>. </p>
<p style="font-family: arial, sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-top: 15px;">

{% if unit_email %}
You were added to this project on behalf of {{displayed_sender}} (<a href="mailto: {{unit_email}}">{{unit_email}}</a>).
If you experience issues, please contact the SciLifeLab unit <b>{{displayed_sender}}</b> at <a href="mailto: {{unit_email}}">{{unit_email}}</a>.
{% else %}
You were added to this project by {{displayed_sender}}.
If you experience issues, please contact the SciLifeLab unit <b>{{displayed_sender}}</b>.
{% endif %}
</p>
<p style="font-family: arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; Margin-top: 0px;">
The DDS CLI command <i>dds ls -p {{project_id}}</i> can be used to list the files in this project. </p>
<p style="font-family: arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; Margin-top: 0px;">
The DDS CLI command <i>dds data get -p {{project_id}} -a --verify-checksum</i> can be used to download all the files in this project to your current directory. </p>
<p style=" font-family: arial, sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-top: 15px;">
Your access to this project will expire on {{deadline}}</p>
<p style=" font-family: arial, sans-serif; font-size: 20px; font-weight: bold; margin: 0; Margin-top: 15px; text-align: center;">
Your access to this project will expire on: <br> <FONT COLOR="RED">{{deadline}}</FONT></p>
<p style="font-family: arial, sans-serif; font-size: 10px; font-weight: normal; margin: 0; Margin-top: 10px;">
<b>What is the DDS?</b> The DDS is a system for SciLifeLab infrastructures to deliver data to researchers in a fast, secure and simple
way.</p>

<b>What is the DDS?</b> The DDS is a system for SciLifeLab infrastructures to deliver data to researchers in a fast, secure and simple way.</p>
</td>
</tr>
</table>
Expand Down
20 changes: 13 additions & 7 deletions dds_web/templates/mail/project_release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ The following project is now available for your access in the SciLifeLab Data De
- Project Title: {{project_title}}
- DDS project ID: {{project_id}}

{% if unit_email %}
You were added to this project on behalf of {{displayed_sender}} ({{unit_email}}).
{% else %}
You were added to this project by {{displayed_sender}}.
{% endif %}
You were added to this project {% if unit_email %} on behalf of {% else %} by {% endif %} {{displayed_sender}}.

The DDS CLI command 'dds ls -p {{project_id}}' can be used to list the files in this project.
To list the files in this project, run:
dds ls -p {{project_id}}

The DDS CLI command 'dds data get -p {{project_id}} -a --verify-checksum' can be used to download all the files in this project to your current directory.
To download all the files in this project to your current directory, run:
dds data get -p {{project_id}} -a --verify-checksum.

For more information (including an installation guide), see the DDS CLI documentation here: https://scilifelabdatacentre.github.io/dds_cli/

{% if unit_email %}
If you experience issues, please contact the SciLifeLab unit {{displayed_sender}} at {{unit_email}}.
{% else %}
If you experience issues, please contact the SciLifeLab unit {{displayed_sender}}.
{% endif %}

Your access to this project will expire on {{deadline}}

Expand Down
15 changes: 14 additions & 1 deletion tests/api/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,10 +1424,23 @@ def test_email_project_release(module_client, boto3_session):
## check plain text message
assert f"- Project Title: {project_title}" in body
assert f"- DDS project ID: {public_project_id}" in body
assert f"dds ls -p {public_project_id}" in body
assert f"dds data get -p {public_project_id} -a --verify-checksum" in body
assert "If you experience issues, please contact the SciLifeLab unit" in body
assert (
"What is the DDS? The DDS is a system for SciLifeLab infrastructures to deliver data to researchers in a fast, secure and simple way"
in body
)

## check html

assert f"<li><b>Project Title:</b> {project_title}</li>" in html
assert f"<li><b>DDS project ID:</b> {public_project_id}</li>" in html
assert f"dds ls -p {public_project_id}" in html
assert f"dds data get -p {public_project_id} -a --verify-checksum" in html
assert "If you experience issues, please contact the SciLifeLab unit" in html
assert (
"<b>What is the DDS?</b> The DDS is a system for SciLifeLab infrastructures to deliver data to researchers in a fast, secure and simple way."
in html
)

assert response.status_code == http.HTTPStatus.OK

0 comments on commit e9a0d1d

Please sign in to comment.