progress on removing postage

This commit is contained in:
stvnrlly
2023-02-10 15:04:59 -05:00
parent 590b3356a1
commit ff3f2c06c0
40 changed files with 189 additions and 798 deletions

View File

@@ -14,7 +14,6 @@ def create_letter_notification(
reply_to_text=None,
billable_units=None,
updated_at=None,
postage=None
):
notification = persist_notification(
template_id=template.id,
@@ -33,9 +32,6 @@ def create_letter_notification(
status=status,
reply_to_text=reply_to_text,
billable_units=billable_units,
# letter_data.get('postage') is only set for precompiled letters
# letters from a template will pass in 'europe' or 'rest-of-world' if None then use postage from template
postage=postage or letter_data.get('postage') or template.postage,
updated_at=updated_at
)
return notification

View File

@@ -24,7 +24,6 @@ from app.dao.notifications_dao import (
)
from app.models import (
EMAIL_TYPE,
INTERNATIONAL_POSTAGE_TYPES,
KEY_TYPE_TEST,
LETTER_TYPE,
NOTIFICATION_CREATED,
@@ -100,7 +99,6 @@ def persist_notification(
status=NOTIFICATION_CREATED,
reply_to_text=None,
billable_units=None,
postage=None,
document_download_count=None,
updated_at=None
):
@@ -148,10 +146,6 @@ def persist_notification(
current_app.logger.info('Persisting notification with type: {}'.format(EMAIL_TYPE))
notification.normalised_to = format_email_address(notification.to)
current_app.logger.info('Persisting notification to formatted email: {}'.format(notification.normalised_to))
elif notification_type == LETTER_TYPE:
notification.postage = postage
notification.international = postage in INTERNATIONAL_POSTAGE_TYPES
notification.normalised_to = ''.join(notification.to.split()).lower()
# if simulated create a Notification model to return but do not persist the Notification to the dB
if not simulated:

View File

@@ -111,7 +111,6 @@ def send_notification(notification_type):
simulated = simulated_recipient(notification_form['to'], notification_type)
notification_model = persist_notification(template_id=template.id,
template_version=template.version,
postage=template.postage,
recipient=request.get_json()['to'],
service=authenticated_service,
personalisation=notification_form.get('personalisation', None),

View File

@@ -240,34 +240,3 @@ def check_service_letter_contact_id(service_id, letter_contact_id, notification_
message = 'letter_contact_id {} does not exist in database for service id {}' \
.format(letter_contact_id, service_id)
raise BadRequestError(message=message)
def validate_address(service, letter_data):
address = PostalAddress.from_personalisation(
letter_data,
allow_international_letters=(INTERNATIONAL_LETTERS in str(service.permissions)),
)
if not address.has_enough_lines:
raise ValidationError(
message=f'Address must be at least {PostalAddress.MIN_LINES} lines'
)
if address.has_too_many_lines:
raise ValidationError(
message=f'Address must be no more than {PostalAddress.MAX_LINES} lines'
)
if not address.has_valid_last_line:
if address.allow_international_letters:
raise ValidationError(
message='Last line of address must be a real UK postcode or another country'
)
raise ValidationError(
message='Must be a real UK postcode'
)
if address.has_invalid_characters:
raise ValidationError(
message='Address lines must not start with any of the following characters: @ ( ) = [ ] ” \\ / , < >'
)
if address.international:
return address.postage
else:
return None