changeset 886:3d635fd53ef0

Merge with upstream.
author Brian Neal <bgneal@gmail.com>
date Tue, 03 Feb 2015 19:52:09 -0600
parents f12751259f66 (current diff) ee47122d6277 (diff)
children 9a15f7c27526
files
diffstat 3 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/core/image_uploader.py	Tue Feb 03 19:51:12 2015 -0600
+++ b/core/image_uploader.py	Tue Feb 03 19:52:09 2015 -0600
@@ -3,6 +3,7 @@
 The image can be resized and a thumbnail can be generated and uploaded as well.
 
 """
+from base64 import b64encode
 import logging
 from io import BytesIO
 import os.path
@@ -18,6 +19,11 @@
 logger = logging.getLogger(__name__)
 
 
+def make_key():
+    """Generate a random key suitable for a filename"""
+    return b64encode(uuid.uuid4().bytes, '-_').rstrip('=')
+
+
 def upload(fp, bucket, metadata=None, new_size=None, thumb_size=None):
     """Upload an image file to a given S3Bucket.
 
@@ -54,7 +60,7 @@
     # to perform on it fail if this is the case. To get around these issues,
     # we make a copy of the file on the file system and operate on the copy.
     # First generate a unique name and temporary file path.
-    unique_key = uuid.uuid4().hex
+    unique_key = make_key()
     ext = os.path.splitext(fp.name)[1]
     temp_name = os.path.join(tempfile.gettempdir(), unique_key + ext)
 
--- a/sg101/templates/base.html	Tue Feb 03 19:51:12 2015 -0600
+++ b/sg101/templates/base.html	Tue Feb 03 19:52:09 2015 -0600
@@ -92,9 +92,9 @@
 
 <div id="content-primary" class="span-19 last">
    <div>
-      <a href="/forums/topic/24943/">
-         <img src="{{ STATIC_URL }}images/NSSRTopAlbum101-2014.png" alt="Top 101 Banner"
-            title="Vote for your favorite surf instrumentals" /></a>
+      <a href="/forums/topic/25265/">
+         <img src="{{ STATIC_URL }}images/NSSRLatin.png" alt="Latin Top 61 Banner"
+            title="Vote for your favorite Latin American surf instrumentals" /></a>
    </div>
    {% block content %}
    {% endblock %}
Binary file static/images/NSSRLatin.png has changed