Merge pull request #22215 from edx/awais786/BOM-1005

BOM-1005
This commit is contained in:
Awais Qureshi
2019-11-01 19:29:02 +05:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@@ -3293,6 +3293,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
self.assertTrue(
body.endswith('"{user_id}","41","42"\n'.format(user_id=self.students[-1].id))
)
self.assertIn("attachment; filename=org", response['Content-Disposition'])
@patch('lms.djangoapps.instructor_task.models.logger.error')
@patch.dict(settings.GRADES_DOWNLOAD, {'STORAGE_TYPE': 's3'})

View File

@@ -1943,7 +1943,9 @@ def get_anon_ids(request, course_id): # pylint: disable=unused-argument
def csv_response(filename, header, rows):
"""Returns a CSV http response for the given header and rows (excel/utf-8)."""
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = u'attachment; filename={0}'.format(text_type(filename).encode('utf-8'))
response['Content-Disposition'] = u'attachment; filename={0}'.format(
text_type(filename).encode('utf-8') if six.PY2 else text_type(filename)
)
writer = csv.writer(response, dialect='excel', quotechar='"', quoting=csv.QUOTE_ALL)
# In practice, there should not be non-ascii data in this query,
# but trying to do the right thing anyway.