summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authoradityacp2018-06-26 16:03:10 +0530
committeradityacp2018-06-26 16:03:10 +0530
commitddd2981529798b8c59dec33e50ccf6e808f3bc19 (patch)
tree946b2bf9b4eee1c82188cd438e3342e2fb2cc900 /yaksh/views.py
parenta200623e1739cb85c5125b0c5115663489e51633 (diff)
downloadonline_test-ddd2981529798b8c59dec33e50ccf6e808f3bc19.tar.gz
online_test-ddd2981529798b8c59dec33e50ccf6e808f3bc19.tar.bz2
online_test-ddd2981529798b8c59dec33e50ccf6e808f3bc19.zip
Fix course download to support Python 2 and 3
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index c5c5be1..f159411 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -2830,16 +2830,13 @@ def download_course(request, course_id):
if not course.has_lessons():
raise Http404("{0} course does not have any lessons".format(
course.name))
- file_name = string_io()
current_dir = os.path.dirname(__file__)
course_name = course.name.replace(" ", "_")
- zip_file = zipfile.ZipFile(file_name, "w")
- course.create_zip(zip_file, current_dir)
- zip_file.close()
- file_name.seek(0)
+ zip_file = course.create_zip(current_dir)
+ zip_file.seek(0)
response = HttpResponse(content_type='application/zip')
response['Content-Disposition'] = 'attachment; filename={0}.zip'.format(
course_name
)
- response.write(file_name.read())
+ response.write(zip_file.read())
return response