Exemplo n.º 1
0
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
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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/'
         )
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 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/'
         )
Exemplo n.º 7
0
 def s3_url(format, zipcode):
     path = settings.HOUSING_COUNSELOR_S3_PATH_TEMPLATE.format(
         format=format,
         zipcode=zipcode
     )
     return https_s3_url_prefix() + path