further prettify
authorJan Szejko <janek37@gmail.com>
Mon, 16 Jan 2017 09:17:28 +0000 (10:17 +0100)
committerJan Szejko <janek37@gmail.com>
Mon, 16 Jan 2017 09:17:28 +0000 (10:17 +0100)
stage2/views.py

index 59c2d82..ca9f935 100644 (file)
@@ -55,7 +55,8 @@ def attachment_download(attachment):
     response = HttpResponse(content_type='application/force-download')
     response.write(attachment.file.read())
     base, ext = attachment.filename().rsplit('.', 1)
-    response['Content-Disposition'] = 'attachment; filename="%s.%s"' % (base[:20].replace('\n', '').strip(), ext)
+    response['Content-Disposition'] = 'attachment; filename="%s.%s"' % (
+        base.strip()[:20].replace('\n', '').strip(), ext)
     response['Content-Length'] = response.tell()
     return response