Skip to content

Commit

Permalink
when user opted out of some but not all domains, limit the list in th…
Browse files Browse the repository at this point in the history
…e notification emails to clearly show the domains to be contacted about vs those the user requested be left alone.
  • Loading branch information
pbugni committed Apr 22, 2024
1 parent e0bb35f commit 7e2f6d3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion portal/trigger_states/empro_messages.py
Expand Up @@ -99,14 +99,19 @@ def staff_emails(patient, hard_triggers, opted_out_domains, initial_notification
if c.id not in staff_list_ids:
staff_list.append(c)

# opt-in holds hard triggers the user did NOT opt-out of
opt_in_domains = hard_triggers

app_text_name = 'empro clinician trigger reminder'
if initial_notification:
app_text_name = 'empro clinician trigger notification'
if not (set(hard_triggers) - set(opted_out_domains)):
# All triggered were opted out of - pick up different email template
app_text_name += " all opted out"
opt_in_domains = []
elif opted_out_domains:
app_text_name += " partially opted out"
opt_in_domains = list(set(hard_triggers) - set(opted_out_domains))

# According to spec, args need at least:
# - study ID
Expand Down Expand Up @@ -134,7 +139,7 @@ def staff_emails(patient, hard_triggers, opted_out_domains, initial_notification
label=_('View Participant Details')))
opted_out = ", ".join(opted_out_domains) if opted_out_domains else ""
opted_out_display = "<b>{opted_out}</b>".format(opted_out=opted_out)
triggered_domains = ", ".join(hard_triggers) if hard_triggers else ""
triggered_domains = ", ".join(opt_in_domains) if opt_in_domains else ""
triggered_domains_display = "<b>{triggered_domains}</b>".format(
triggered_domains=triggered_domains)
args = {
Expand Down

0 comments on commit 7e2f6d3

Please sign in to comment.