mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
Let users search for letters
Like we have search by email address or phone number, finding an individual letter is a common task. At the moment users are having to click through pages and pages of letters to find the one they’re looking for. We have to search in the `to` and `normalised_to` fields for now because we’re not populating the `normalised_to` column for letters at the moment.
This commit is contained in:
@@ -26,7 +26,6 @@ from werkzeug.datastructures import MultiDict
|
||||
from app import db, create_uuid
|
||||
from app.aws.s3 import remove_s3_object, get_s3_bucket_objects
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.errors import InvalidRequest
|
||||
from app.letters.utils import get_letter_pdf_filename
|
||||
from app.models import (
|
||||
FactNotificationStatus,
|
||||
@@ -600,11 +599,8 @@ def dao_get_notifications_by_recipient_or_reference(service_id, search_term, not
|
||||
except InvalidEmailError:
|
||||
normalised = search_term.lower()
|
||||
|
||||
elif notification_type == LETTER_TYPE:
|
||||
raise InvalidRequest("Only email and SMS can use search by recipient", 400)
|
||||
|
||||
else:
|
||||
normalised = search_term.lower()
|
||||
normalised = ''.join(search_term.split()).lower()
|
||||
|
||||
normalised = escape_special_characters(normalised)
|
||||
search_term = escape_special_characters(search_term)
|
||||
@@ -612,6 +608,7 @@ def dao_get_notifications_by_recipient_or_reference(service_id, search_term, not
|
||||
filters = [
|
||||
Notification.service_id == service_id,
|
||||
or_(
|
||||
Notification.to.ilike("%{}%".format(search_term)),
|
||||
Notification.normalised_to.like("%{}%".format(normalised)),
|
||||
Notification.client_reference.ilike("%{}%".format(search_term)),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user