Skip to content

Commit 876a9f7

Browse files
authored
TN-3331 prevent staff users from sending bogus reminder emails (#4430)
TN-3331 describes symptoms as we didn't previously confirm a reminder email was appropriate to send, if requested by staff. No longer generating email content, or sending email, unless the user has outstanding work, when the user (staff) requests to send a reminder email.
2 parents 17217ad + 86856e4 commit 876a9f7

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

portal/static/js/src/profile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,8 @@ export default (function() {
20822082
resetBtn(true);
20832083
});
20842084
}).fail(function(xhr) { //report error
2085-
self.messages.userInviteEmailErrorMessage = i18next.t("Error occurred retreving email content via API.");
2085+
const message = `${i18next.t("Error occurred retreving email content via API.")} ${xhr && xhr.responseText ? xhr.responseText: ""}`;
2086+
self.messages.userInviteEmailErrorMessage = message;
20862087
resetBtn();
20872088
self.modules.tnthAjax.reportError(self.subjectId, emailUrl, xhr.responseText);
20882089
});

portal/static/less/eproms.less

+18
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,24 @@ body {
267267
min-height: 8px;
268268
}
269269
}
270+
.clamped-container {
271+
font-size: 1em;
272+
display: block; /* Fallback for non-webkit */
273+
display: -webkit-box;
274+
height: 8.4em;
275+
line-height: 1.4em;
276+
-webkit-line-clamp: 6;
277+
-webkit-box-orient: vertical;
278+
overflow: hidden;
279+
text-overflow: ellipsis;
280+
h1,h2,h3,h4,h5,h6 {
281+
display: none;
282+
}
283+
&:empty {
284+
height: 0;
285+
-webkit-line-clamp: 0;
286+
}
287+
}
270288
#fillOrgs.org-tree {
271289
flex-direction: row;
272290
}

portal/templates/profile/profile_macros.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ <h4 class="{{prefix}}-label text-success" v-if="!patientReport.hasP3PReport">{{_
308308
<div id="profile{{prefix}}EmailBtnMsgWrapper" class="profilePatientEmail__btn-msg-wrapper tnth-hide">
309309
<div id="profile{{prefix}}EmailLoadingIndicator" v-show="patientEmailForm.loading"><i class="fa fa-spinner fa-spin fa-2x"></i></div>
310310
<div id="profile{{prefix}}EmailMessage" class="send-email-info text-info" v-html="messages.userInviteEmailInfoMessage"></div>
311-
<div id="profile{{prefix}}EmailErrorMessage" class="send-email-info text-danger" v-html="messages.userInviteEmailErrorMessage"></div>
311+
<div id="profile{{prefix}}EmailErrorMessage" class="send-email-info text-danger clamped-container" v-html="messages.userInviteEmailErrorMessage"></div>
312312
</div>
313313
{{emailReadyMessage()}}
314314
</div>

portal/views/portal.py

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from flask_wtf import FlaskForm
3333
from sqlalchemy import and_
3434
from sqlalchemy.orm.exc import NoResultFound
35+
from werkzeug.exceptions import BadRequest
3536
from wtforms import (
3637
BooleanField,
3738
HiddenField,
@@ -70,6 +71,7 @@
7071
OrgTree,
7172
UserOrganization,
7273
)
74+
from ..models.overall_status import OverallStatus
7375
from ..models.research_study import EMPRO_RS_ID, ResearchStudy
7476
from ..models.role import ALL_BUT_WRITE_ONLY, ROLE
7577
from ..models.table_preference import TablePreference
@@ -749,6 +751,7 @@ def patient_reminder_email(user_id):
749751
Query string
750752
:param research_study_id: set for targeted reminder emails, defaults to 0
751753
754+
:raises werkzeug.exceptions.BadRequest: if the patient isn't currently eligible for reminder
752755
"""
753756
from ..models.qb_status import QB_Status
754757
user = get_user(user_id, 'edit')
@@ -767,6 +770,10 @@ def patient_reminder_email(user_id):
767770
user,
768771
research_study_id=research_study_id,
769772
as_of_date=datetime.utcnow())
773+
if qstats.overall_status not in (
774+
OverallStatus.due, OverallStatus.overdue, OverallStatus.in_progress):
775+
raise BadRequest(_('No questionnaire is due.'))
776+
770777
qbd = qstats.current_qbd()
771778
if qbd:
772779
qb_id, qb_iteration = qbd.qb_id, qbd.iteration

0 commit comments

Comments
 (0)