mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-26 17:23:50 -04:00
Merge pull request #2809 from alphagov/bump-utils-38.0.0
Bump utils to 39.0.0
This commit is contained in:
@@ -40,6 +40,7 @@ from app.letters.utils import (
|
||||
get_file_names_from_error_bucket,
|
||||
)
|
||||
from app.models import (
|
||||
INTERNATIONAL_LETTERS,
|
||||
KEY_TYPE_TEST,
|
||||
NOTIFICATION_CREATED,
|
||||
NOTIFICATION_DELIVERED,
|
||||
@@ -227,6 +228,9 @@ def sanitise_letter(self, filename):
|
||||
kwargs={
|
||||
'notification_id': str(notification.id),
|
||||
'filename': filename,
|
||||
'allow_international_letters': notification.service.has_permission(
|
||||
INTERNATIONAL_LETTERS
|
||||
),
|
||||
},
|
||||
queue=QueueNames.SANITISE_LETTERS,
|
||||
)
|
||||
|
||||
@@ -126,9 +126,7 @@ def get_recipient_csv_and_template_and_sender_id(job):
|
||||
template = db_template._as_utils_template()
|
||||
|
||||
contents, meta_data = s3.get_job_and_metadata_from_s3(service_id=str(job.service_id), job_id=str(job.id))
|
||||
recipient_csv = RecipientCSV(file_data=contents,
|
||||
template_type=template.template_type,
|
||||
placeholders=template.placeholders)
|
||||
recipient_csv = RecipientCSV(contents, template=template)
|
||||
|
||||
return recipient_csv, template, meta_data.get("sender_id")
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ from app.models import (
|
||||
NOTIFICATION_SENDING,
|
||||
NOTIFICATION_DELIVERED,
|
||||
NOTIFICATION_PENDING_VIRUS_CHECK,
|
||||
INTERNATIONAL_LETTERS,
|
||||
Notification)
|
||||
from app.notifications.process_letter_notifications import (
|
||||
create_letter_notification
|
||||
@@ -345,7 +346,10 @@ def process_letter_notification(*, letter_data, api_key, template, reply_to_text
|
||||
template=template,
|
||||
reply_to_text=reply_to_text)
|
||||
|
||||
address = PostalAddress.from_personalisation(letter_data['personalisation'])
|
||||
address = PostalAddress.from_personalisation(
|
||||
letter_data['personalisation'],
|
||||
allow_international_letters=api_key.service.has_permission(INTERNATIONAL_LETTERS),
|
||||
)
|
||||
|
||||
if not address.has_enough_lines:
|
||||
raise ValidationError(
|
||||
@@ -357,7 +361,11 @@ def process_letter_notification(*, letter_data, api_key, template, reply_to_text
|
||||
message=f'Address must be no more than {PostalAddress.MAX_LINES} lines'
|
||||
)
|
||||
|
||||
if not address.postcode:
|
||||
if not address.has_valid_last_line:
|
||||
if address.allow_international_letters:
|
||||
raise ValidationError(
|
||||
message=f'Last line of address must be a real UK postcode or another country'
|
||||
)
|
||||
raise ValidationError(
|
||||
message='Must be a real UK postcode'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user