From ddd2981529798b8c59dec33e50ccf6e808f3bc19 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 26 Jun 2018 16:03:10 +0530 Subject: Fix course download to support Python 2 and 3 --- yaksh/views.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'yaksh/views.py') 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 -- cgit