Ejemplo 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
Ejemplo n.º 2
0
 def test_http_s3_url_prefix_no_setting(self):
     with self.settings(AWS_STORAGE_BUCKET_NAME=None):
         with self.assertRaises(RuntimeError):
             http_s3_url_prefix()
Ejemplo n.º 3
0
 def test_http_s3_url_prefix(self):
     with self.settings(AWS_STORAGE_BUCKET_NAME='foo.bucket'):
         self.assertEqual(
             http_s3_url_prefix(),
             'http://foo.bucket/'
         )
Ejemplo n.º 4
0
 def test_http_s3_url_prefix_no_setting(self):
     with self.settings(AWS_STORAGE_BUCKET_NAME=None):
         with self.assertRaises(RuntimeError):
             http_s3_url_prefix()
Ejemplo n.º 5
0
 def test_http_s3_url_prefix(self):
     with self.settings(AWS_STORAGE_BUCKET_NAME='foo.bucket'):
         self.assertEqual(
             http_s3_url_prefix(),
             'http://foo.bucket/'
         )