Skip to content

Commit fe44b53

Browse files
authored
Merge commit from fork
1 parent 1aa4c76 commit fe44b53

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,6 @@ gem 'uri', '0.10.3'
177177

178178
# To generate slugged urls
179179
gem 'friendly_id', '~> 5.5.0'
180+
181+
# to sanitize CSV files
182+
gem 'csv-safe'

Gemfile.lock

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ GEM
115115
crack (0.4.5)
116116
rexml
117117
crass (1.0.6)
118+
csv (3.3.0)
119+
csv-safe (3.3.1)
120+
csv (~> 3.0)
118121
daemons (1.4.1)
119122
database_cleaner (2.0.2)
120123
database_cleaner-active_record (>= 2, < 3)
@@ -482,6 +485,7 @@ DEPENDENCIES
482485
capybara
483486
codeclimate-test-reporter
484487
coffee-rails (>= 4.0.0)
488+
csv-safe
485489
database_cleaner
486490
devise (>= 4.5.0)
487491
diffy

app/controllers/courses_controller.rb

+9-8
Original file line numberDiff line numberDiff line change
@@ -570,15 +570,16 @@ def download_roster
570570
@cuds = @course.course_user_data.where(instructor: false,
571571
course_assistant: false,
572572
dropped: false)
573-
output = ""
574-
@cuds.each do |cud|
575-
user = cud.user
576-
# to_csv avoids issues with commas
577-
output += [@course.semester, cud.user.email, user.last_name, user.first_name,
578-
cud.school, cud.major, cud.year, cud.grade_policy,
579-
cud.course_number, cud.lecture, cud.section].to_csv
573+
csv_content = CSVSafe.generate do |csv|
574+
@cuds.each do |cud|
575+
user = cud.user
576+
# to_csv avoids issues with commas
577+
csv << [@course.semester, cud.user.email, user.last_name, user.first_name,
578+
cud.school, cud.major, cud.year, cud.grade_policy,
579+
cud.course_number, cud.lecture, cud.section]
580+
end
580581
end
581-
send_data output, filename: "roster.csv", type: "text/csv", disposition: "inline"
582+
send_data csv_content, filename: "roster.csv", type: "text/csv", disposition: "inline"
582583
end
583584

584585
# email - The email action allows instructors to email the entire course, or

0 commit comments

Comments
 (0)