forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3018 from raft-tech/2473-data-submission-notifica…
…tion 2473 - Upcoming data deadline notification
- Loading branch information
Showing
6 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tdrs-backend/tdpservice/email/templates/upcoming-submission-deadline.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends 'base.html' %} | ||
{% block content %} | ||
|
||
<!-- Body copy --> | ||
<p>Hello {{ first_name }},</p> | ||
<p>This is a friendly reminder that your data files are due in 5 days. </p> | ||
<p>Please sign in to the <a href="{{ url }}" target="_blank">TANF Data Portal</a> | ||
to upload and submit data files for <b>Fiscal Year {{ fiscal_year }} - {{ fiscal_quarter}}</b> by <b>{{ submission_deadline }}.</b></p> | ||
|
||
<!-- This link uses descriptive text to inform the user what will happen with the link is tapped. --> | ||
<!-- It also uses inline styles since some email clients won't render embedded styles from the head. --> | ||
<!-- <a href="" style="color: #336a90; text-decoration: underline;">Reset your password now</a> --> | ||
<p><a class="button" href="{{ url }}" style="background-color:#336a90;border-radius:4px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:18px;font-weight:bold;line-height:60px;text-align:center;text-decoration:none;width: auto; padding-left: 24px; padding-right: 24px;-webkit-text-size-adjust:none;">Submit your data files</a></p> | ||
|
||
<b>Need help?</b><br> | ||
We're here for you! Check out the <a href="http://tdp-project-updates.app.cloud.gov/knowledge-center/" target="_blank">TDP Knowledge Center</a> for specific gudiance on <a href="https://tdp-project-updates.app.cloud.gov/knowledge-center/uploading-data.html" target="_blank">Submitting Data Files</a> and <a href="https://tdp-project-updates.app.cloud.gov/knowledge-center/faq.html">Frequently Asked Questions</a>. | ||
<p> | ||
TDP is now the only method for data submissions; you should not be submitting data through SFTP or Cyberfusion. Please reach out to the TDP support team at <a href="mailto:[email protected]" target="_blank">[email protected]</a> if you have any questions or need assistance. | ||
<p>Thank you,</p> | ||
<p>The TDP Team</p> | ||
|
||
|
||
<!-- This link uses descriptive text to inform the user what will happen with the link is tapped. --> | ||
<!-- It also uses inline styles since some email clients won't render embedded styles from the head. --> | ||
<!-- <a href="" style="color: #336a90; text-decoration: underline;">Reset your password now</a> --> | ||
|
||
{% endblock %} |
134 changes: 134 additions & 0 deletions
134
tdrs-backend/tdpservice/email/test/test_upcoming_deadline_email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
"""Test function for sending upcoming data deadline reminders.""" | ||
import pytest | ||
from datetime import datetime | ||
from django.core import mail | ||
from tdpservice.email.tasks import send_data_submission_reminder | ||
from django.contrib.auth.models import Group | ||
from tdpservice.stts.models import STT | ||
from tdpservice.users.models import User | ||
from tdpservice.data_files.models import DataFile | ||
|
||
|
||
@pytest.mark.parametrize('due_date, reporting_period, fiscal_quarter', [ | ||
('February 14', 'Oct - Dec', 'Q1'), | ||
('May 15th', 'Jan - Mar', 'Q2'), | ||
('August 14th', 'Apr - Jun', 'Q3'), | ||
('November 14th', 'Jul - Sep', 'Q4'), | ||
]) | ||
@pytest.mark.django_db | ||
def test_upcoming_deadline_sends_no_sections_submitted( | ||
due_date, reporting_period, fiscal_quarter): | ||
"""Test that the send_deactivation_warning_email function runs when no sections have been submitted.""" | ||
stt = STT.objects.create( | ||
name='Arkansas', | ||
filenames={ | ||
"Active Case Data": "test-filename.txt", | ||
"Closed Case Data": "test-filename-closed.txt", | ||
} | ||
) | ||
|
||
data_analyst = User.objects.create( | ||
username='[email protected]', | ||
stt=stt, | ||
account_approval_status='Approved' | ||
) | ||
data_analyst.groups.add(Group.objects.get(name='Data Analyst')) | ||
data_analyst.save() | ||
|
||
send_data_submission_reminder(due_date, reporting_period, fiscal_quarter) | ||
|
||
assert len(mail.outbox) == 1 | ||
assert mail.outbox[0].subject == "Action Requested: Please submit your TANF data files" | ||
|
||
|
||
@pytest.mark.parametrize('due_date, reporting_period, fiscal_quarter', [ | ||
('February 14', 'Oct - Dec', 'Q1'), | ||
('May 15th', 'Jan - Mar', 'Q2'), | ||
('August 14th', 'Apr - Jun', 'Q3'), | ||
('November 14th', 'Jul - Sep', 'Q4'), | ||
]) | ||
@pytest.mark.django_db | ||
def test_upcoming_deadline_sends_some_sections_submitted( | ||
due_date, reporting_period, fiscal_quarter): | ||
"""Test that the send_deactivation_warning_email function runs when some sections have been submitted.""" | ||
stt = STT.objects.create( | ||
name='Arkansas', | ||
filenames={ | ||
"Active Case Data": "test-filename.txt", | ||
"Closed Case Data": "test-filename-closed.txt", | ||
} | ||
) | ||
|
||
data_analyst = User.objects.create( | ||
username='[email protected]', | ||
stt=stt, | ||
account_approval_status='Approved' | ||
) | ||
data_analyst.groups.add(Group.objects.get(name='Data Analyst')) | ||
data_analyst.save() | ||
|
||
now = datetime.now() | ||
fiscal_year = now.year - 1 if fiscal_quarter == 'Q1' else now.year | ||
|
||
_ = DataFile.create_new_version({ | ||
"section": 'Active Case Data', | ||
"quarter": fiscal_quarter, | ||
"year": fiscal_year, | ||
"stt": stt, | ||
"user": data_analyst, | ||
}) | ||
|
||
send_data_submission_reminder(due_date, reporting_period, fiscal_quarter) | ||
|
||
assert len(mail.outbox) == 1 | ||
assert mail.outbox[0].subject == "Action Requested: Please submit your TANF data files" | ||
|
||
|
||
@pytest.mark.parametrize('due_date, reporting_period, fiscal_quarter', [ | ||
('February 14', 'Oct - Dec', 'Q1'), | ||
('May 15th', 'Jan - Mar', 'Q2'), | ||
('August 14th', 'Apr - Jun', 'Q3'), | ||
('November 14th', 'Jul - Sep', 'Q4'), | ||
]) | ||
@pytest.mark.django_db | ||
def test_upcoming_deadline_no_send_when_all_sections_complete( | ||
due_date, reporting_period, fiscal_quarter): | ||
"""Test that the send_deactivation_warning_email function does not run when all sections have been submitted.""" | ||
stt = STT.objects.create( | ||
name='Arkansas', | ||
filenames={ | ||
"Active Case Data": "test-filename.txt", | ||
"Closed Case Data": "test-filename-closed.txt", | ||
} | ||
) | ||
|
||
data_analyst = User.objects.create( | ||
username='[email protected]', | ||
stt=stt, | ||
account_approval_status='Approved' | ||
) | ||
data_analyst.groups.add(Group.objects.get(name='Data Analyst')) | ||
data_analyst.save() | ||
|
||
now = datetime.now() | ||
fiscal_year = now.year - 1 if fiscal_quarter == 'Q1' else now.year | ||
|
||
_ = DataFile.create_new_version({ | ||
"section": 'Active Case Data', | ||
"quarter": fiscal_quarter, | ||
"year": fiscal_year, | ||
"stt": stt, | ||
"user": data_analyst, | ||
}) | ||
|
||
_ = DataFile.create_new_version({ | ||
"section": 'Closed Case Data', | ||
"quarter": fiscal_quarter, | ||
"year": fiscal_year, | ||
"stt": stt, | ||
"user": data_analyst, | ||
}) | ||
|
||
send_data_submission_reminder(due_date, reporting_period, fiscal_quarter) | ||
|
||
assert len(mail.outbox) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters