def process_external_link_field(field): # Convert any HTTP image links to S3 to HTTPS. # noop if AWS_STORAGE_BUCKET_NAME is not set if getattr(settings, 'AWS_STORAGE_BUCKET_NAME', None): field = convert_http_image_links(field, [ (http_s3_url_prefix(), https_s3_url_prefix()), ]) # Add appropriate markup to all links in HTML. field = parse_links(field).encode(formatter=None) return field
def s3_url(format, zipcode): path = settings.HOUSING_COUNSELOR_S3_PATH_TEMPLATE.format( format=format, zipcode=zipcode) return https_s3_url_prefix() + path
def test_https_s3_url_prefix_no_setting(self): with self.settings(AWS_STORAGE_BUCKET_NAME=None): with self.assertRaises(RuntimeError): https_s3_url_prefix()
def test_https_s3_url_prefix(self): with self.settings(AWS_STORAGE_BUCKET_NAME='foo.bucket'): self.assertEqual( https_s3_url_prefix(), 'https://s3.amazonaws.com/foo.bucket/' )
def test_https_s3_url_prefix_no_setting(self): with self.settings(AWS_STORAGE_BUCKET_NAME=None): with self.assertRaises(RuntimeError): https_s3_url_prefix()
def test_https_s3_url_prefix(self): with self.settings(AWS_STORAGE_BUCKET_NAME='foo.bucket'): self.assertEqual( https_s3_url_prefix(), 'https://s3.amazonaws.com/foo.bucket/' )
def s3_url(format, zipcode): path = settings.HOUSING_COUNSELOR_S3_PATH_TEMPLATE.format( format=format, zipcode=zipcode ) return https_s3_url_prefix() + path