feat: warn about duplicate recipients in CSV uploads (#3319)#2708
Open
smcmurtry wants to merge 1 commit into
Open
feat: warn about duplicate recipients in CSV uploads (#3319)#2708smcmurtry wants to merge 1 commit into
smcmurtry wants to merge 1 commit into
Conversation
Surfaces a non-blocking warning on the bulk-send preview page when the uploaded CSV contains the same recipient more than once. The warning is case-insensitive, ignores leading/trailing whitespace, and (for SMS) treats phone numbers in different formats as equivalent. Letters are excluded because multiple recipients can legitimately share an address. Changes: - new get_warnings_for_csv helper in app/utils.py - new download_duplicate_recipients route serves a CSV of duplicate rows so the sender can review them before sending; the response is built server-side from the original upload, so duplicates are visible only to the authenticated sender (privacy) - ok.html renders the warning in a banner inside an aria-live=polite region, including a link to download the duplicates list - EN/FR translation strings added to fr.csv (en.csv and messages.po files are regenerated by 'make babel') - unit tests for get_warnings_for_csv Depends on notifications-utils with duplicate-recipient detection (see corresponding PR in notification-utils). Refs: cds-snc/notification-planning#3319
🧪 Review environmenthttps://egbdkivq2xmyyzxuyq5cta2foq0qbhxv.lambda-url.ca-central-1.on.aws/ |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warn about duplicate recipients in CSV uploads — closes cds-snc/notification-planning#3319
Summary
Surfaces a non-blocking warning on the bulk-send preview page when the
uploaded CSV contains the same recipient more than once. Senders can review
the warning, download a list of duplicates, and either proceed with the send
or go back and fix their list.
What's new
Backend
app/utils.py— newget_warnings_for_csv()helper that returnsuser-facing warning strings (currently: duplicate recipients). Letters are
exempt because multiple recipients can legitimately share an address.
app/main/views/send.py— wires the new warnings into the_check_messagesdata dict, alongsidecount_of_duplicate_recipientsandcount_of_duplicate_recipient_rows.download_duplicate_recipientsthat returns a CSV containingonly the duplicate rows. The CSV is built server-side from the original S3
upload (which is scoped to the authenticated user via
@user_has_permissions("send_messages", restrict_admin_usage=True)), soduplicates are only ever visible to the sender — privacy preserved.
UI
app/templates/views/check/ok.html— a yellow "warning" banner isrendered at the top of the bulk-send review page when duplicates are
detected. Includes:
aria-live="polite"for screen-reader usersdata-testid="duplicate-recipients-warning"for Cypress hooksTranslations
EN/FR strings for the warning are added to
app/translations/csv/fr.csv. Thegenerated
en.csv/messages.pofiles are produced bymake babeland aregitignored.
Detection rules (delivered by notifications-utils)
Alice@Example.comandALICE@EXAMPLE.COMare duplicates.6502532222,+1 650-253-2222and650 253 2222recognised as the same recipient.Tests
tests/app/main/test_warnings_for_csv.pycoversget_warnings_for_csvfor all branches (no duplicates, singular, plural,letter exemption, row-count subline).
notifications-utils PR.
A11y / privacy / security
aria-live="polite"region and uses theexisting accessible
banner_wrappermacro.authenticated user's own upload and is never persisted; only the sender can
download it.
filename is sanitised via
SanitiseASCII, and the response uses theexisting
Spreadsheethelper.Companion PR (must merge first)
Depends on duplicate-recipient detection in
notification-utils #fix/3319-warn-duplicate-recipients
(version
53.2.25).Closes cds-snc/notification-planning#3319.