diff options
author | adityacp | 2018-06-26 16:03:10 +0530 |
---|---|---|
committer | adityacp | 2018-06-26 16:03:10 +0530 |
commit | ddd2981529798b8c59dec33e50ccf6e808f3bc19 (patch) | |
tree | 946b2bf9b4eee1c82188cd438e3342e2fb2cc900 /yaksh/views.py | |
parent | a200623e1739cb85c5125b0c5115663489e51633 (diff) | |
download | online_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.py | 9 |
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 |