Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

MEI-15697 Staff tools - download failure #2168

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lms/djangoapps/instructor_task/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ def from_config(cls, config_name):
)
return DjangoStorageReportStore.from_config(config_name)

def _get_utf8_encoded_rows(self, rows):
def _get_utf8_encoded_rows(self, rows, encode_for_utf8=False):
"""
Given a list of `rows` containing unicode strings, return a
new list of rows with those strings encoded as utf-8 for CSV
compatibility.
"""
for row in rows:
if six.PY2:
if six.PY2 or encode_for_utf8:
yield [six.text_type(item).encode('utf-8') for item in row]
else:
yield [six.text_type(item) for item in row]
Expand Down Expand Up @@ -315,9 +315,9 @@ def store_rows(self, course_id, filename, rows):
if six.PY2:
output_buffer.write(codecs.BOM_UTF8)
csvwriter = csv.writer(output_buffer)
csvwriter.writerows(self._get_utf8_encoded_rows(rows))
csvwriter.writerows(self._get_utf8_encoded_rows(rows, encode_for_utf8=True))
output_buffer.seek(0)
self.store(course_id, filename, output_buffer)
self.store(course_id, filename, output_buffer, batched=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The store_rows usage of the instructor_task app is widespread as it's being used in different xblocks as well as edx itself. So It's good to do the change where it's impacting and use add_rows and call store method rather than changing in a core function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mudassir-hafeez
I have updated the Pull Request and used default arguments in store_rows so that the widespread usage of this method doesn't get affected.

def links_for(self, course_id):
"""
Expand Down