changeset 528:311c926dd218

Must urlencode the filenames.
author Brian Neal <bgneal@gmail.com>
date Wed, 21 Dec 2011 01:25:10 +0000
parents 645025056dfa
children 7388cdf61b25
files gpp/downloads/management/commands/dlwgetcat.py gpp/templates/downloads/commands/category_report.html gpp/templates/downloads/commands/wget_cat.html
diffstat 3 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/downloads/management/commands/dlwgetcat.py	Wed Dec 21 01:08:21 2011 +0000
+++ b/gpp/downloads/management/commands/dlwgetcat.py	Wed Dec 21 01:25:10 2011 +0000
@@ -34,8 +34,6 @@
         downloads = Download.public_objects.filter(category=category).order_by(
                 'title').select_related()
 
-        current_site = Site.objects.get_current()
-
         # Create new destination names for the files since the uploaders often
         # give the files terrible names. The new names will be slugified
         # versions of the titles, with the same extension.
@@ -44,12 +42,10 @@
             ext = os.path.splitext(dl.file.name)[1]
             dl.dest_filename = slugify(dl.title) + ext
 
-            # build a full URL to the download
-            dl.full_url = 'http://%s%s%s' % (current_site.domain,
-                    settings.MEDIA_URL, dl.file.name)
-
         output = render_to_string('downloads/commands/wget_cat.html', {
             'downloads': downloads,
+            'domain': Site.objects.get_current().domain,
+            'MEDIA_URL': settings.MEDIA_URL,
             })
 
         # encode it ourselves since it can fail if you try to redirect output to
--- a/gpp/templates/downloads/commands/category_report.html	Wed Dec 21 01:08:21 2011 +0000
+++ b/gpp/templates/downloads/commands/category_report.html	Wed Dec 21 01:25:10 2011 +0000
@@ -7,7 +7,7 @@
       <h1>Download Report: {{ category.title }}</h1>
       {% for dl in downloads %}
          <h2>{{ dl.title }}</h2>
-         <p><em>Uploaded by {{ dl.user.username }}.</em></p>
+         <p><small><em>Uploaded by {{ dl.user.username }}.</em></small></p>
          <div>{{ dl.html|safe }}</div>
       {% endfor %}
    </body>
--- a/gpp/templates/downloads/commands/wget_cat.html	Wed Dec 21 01:08:21 2011 +0000
+++ b/gpp/templates/downloads/commands/wget_cat.html	Wed Dec 21 01:25:10 2011 +0000
@@ -1,5 +1,5 @@
 #!/bin/bash
 
 {% for dl in downloads %}
-wget -O {{ dl.dest_filename }} {{ dl.full_url }}
+wget -O {{ dl.dest_filename }} http://{{ domain }}{{ MEDIA_URL }}{{ dl.file.name|urlencode }}
 {% endfor %}