Compare commits

..

1 Commits

Author SHA1 Message Date
Leo Hemsted
72b482487f remove sandbox
we haven't used this in five years. we set up sandbox once but never
actually had any concrete uses for spinning up an entire extra infra
setup outside the main deploy pipeline. none of these buckets exist and
no doubt the AWS infra is significantly out of date too.
2022-04-12 15:06:25 +01:00
6 changed files with 8 additions and 88 deletions

View File

@@ -546,21 +546,6 @@ class CloudFoundryConfig(Config):
pass
# CloudFoundry sandbox
class Sandbox(CloudFoundryConfig):
NOTIFY_EMAIL_DOMAIN = 'notify.works'
NOTIFY_ENVIRONMENT = 'sandbox'
CSV_UPLOAD_BUCKET_NAME = 'cf-sandbox-notifications-csv-upload'
CONTACT_LIST_BUCKET_NAME = 'cf-sandbox-contact-list'
LETTERS_PDF_BUCKET_NAME = 'cf-sandbox-letters-pdf'
TEST_LETTERS_BUCKET_NAME = 'cf-sandbox-test-letters'
DVLA_RESPONSE_BUCKET_NAME = 'notify.works-ftp'
LETTERS_PDF_BUCKET_NAME = 'cf-sandbox-letters-pdf'
LETTERS_SCAN_BUCKET_NAME = 'cf-sandbox-letters-scan'
INVALID_PDF_BUCKET_NAME = 'cf-sandbox-letters-invalid-pdf'
FROM_NUMBER = 'sandbox'
configs = {
'development': Development,
'test': Test,
@@ -568,5 +553,4 @@ configs = {
'production': Live,
'staging': Staging,
'preview': Preview,
'sandbox': Sandbox
}

View File

@@ -563,7 +563,7 @@ class Service(db.Model, Versioned):
def get_default_letter_contact(self):
default_letter_contact = [x for x in self.letter_contacts if x.is_default]
return default_letter_contact[0] if default_letter_contact else None
return default_letter_contact[0].contact_block if default_letter_contact else None
def has_permission(self, permission):
return permission in [p.permission for p in self.permissions]

View File

@@ -246,6 +246,9 @@ class ServiceSchema(BaseSchema, UUIDsAsStringsMixin):
def service_permissions(self, service):
return [p.permission for p in service.permissions]
def get_letter_contact(self, service):
return service.get_default_letter_contact()
class Meta(BaseSchema.Meta):
model = models.Service
exclude = (

View File

@@ -96,11 +96,8 @@ def create_template(service_id):
errors = {'template_type': [message]}
raise InvalidRequest(errors, 403)
if new_template.template_type == LETTER_TYPE:
if default_letter_contact := fetched_service.get_default_letter_contact():
new_template.reply_to = default_letter_contact.id
if not new_template.postage:
new_template.postage = SECOND_CLASS
if not new_template.postage and new_template.template_type == LETTER_TYPE:
new_template.postage = SECOND_CLASS
new_template.service = fetched_service

View File

@@ -146,70 +146,6 @@ def test_create_a_new_template_for_a_service_adds_postage_for_letters_only(
assert template.postage == expected_postage
@pytest.mark.parametrize("has_a_non_default_letter_contact_only", [True, False])
def test_create_letter_template_adds_no_sender_address_if_no_default_exists(
client, sample_service, has_a_non_default_letter_contact_only
):
# If the service has no letter contacts, then the default sender address is 'not set' and it will be
# blank for the new template
# However they can have a single letter contact which is stored in the DB as not the default, which
# results in the default sender address being 'Blank' rather than 'not set'
# We test both of these situations where we expect the templates sender address to empty
if has_a_non_default_letter_contact_only:
create_letter_contact(sample_service, "Edinburgh, ED1 1AA", is_default=False)
data = {
'name': 'my template',
'template_type': 'letter',
'subject': "my subject",
'content': 'template <b>content</b>',
'service': str(sample_service.id),
'created_by': str(sample_service.users[0].id)
}
data = json.dumps(data)
auth_header = create_admin_authorization_header()
response = client.post(
'/service/{}/template'.format(sample_service.id),
headers=[('Content-Type', 'application/json'), auth_header],
data=data
)
assert response.status_code == 201
created_template = json.loads(response.get_data(as_text=True))['data']
assert created_template['service_letter_contact'] is None
assert created_template['reply_to'] is None
assert created_template['reply_to_text'] is None
def test_create_letter_template_adds_default_sender_address_for_letters_when_exists(
client, sample_service
):
letter_contact = create_letter_contact(sample_service, "Edinburgh, ED1 1AA", is_default=True)
data = {
'name': 'my template',
'template_type': 'letter',
'subject': "my subject",
'content': 'template <b>content</b>',
'service': str(sample_service.id),
'created_by': str(sample_service.users[0].id)
}
data = json.dumps(data)
auth_header = create_admin_authorization_header()
response = client.post(
'/service/{}/template'.format(sample_service.id),
headers=[('Content-Type', 'application/json'), auth_header],
data=data
)
assert response.status_code == 201
created_template = json.loads(response.get_data(as_text=True))['data']
assert created_template['service_letter_contact'] == str(letter_contact.id)
assert created_template['reply_to'] == str(letter_contact.id)
assert created_template['reply_to_text'] == "Edinburgh, ED1 1AA"
def test_create_template_should_return_400_if_folder_is_for_a_different_service(
client, sample_service
):

View File

@@ -274,9 +274,9 @@ def test_service_get_default_reply_to_email_address(sample_service):
def test_service_get_default_contact_letter(sample_service):
letter_contact = create_letter_contact(service=sample_service, contact_block='London,\nNW1A 1AA')
create_letter_contact(service=sample_service, contact_block='London,\nNW1A 1AA')
assert sample_service.get_default_letter_contact() == letter_contact
assert sample_service.get_default_letter_contact() == 'London,\nNW1A 1AA'
def test_service_get_default_sms_sender(notify_db_session):