Merge pull request #21248 from open-craft/samuel/se-1155-fix-ccx-unicode
SE-1155 [Campus.il] fix crashes on non-ascii in usernames for ccx enrollments
This commit is contained in:
@@ -89,7 +89,7 @@ def setup_students_and_grades(context):
|
||||
context.student = student = UserFactory.create()
|
||||
CourseEnrollmentFactory.create(user=student, course_id=context.course.id)
|
||||
|
||||
context.student2 = student2 = UserFactory.create()
|
||||
context.student2 = student2 = UserFactory.create(username=u'u\u0131\u028c\u0279\u0250\u026f')
|
||||
CourseEnrollmentFactory.create(user=student2, course_id=context.course.id)
|
||||
|
||||
# create grades for self.student as if they'd submitted the ccx
|
||||
|
||||
@@ -260,14 +260,14 @@ def ccx_students_enrolling_center(action, identifiers, email_students, course_ke
|
||||
if student:
|
||||
must_enroll = student in staff or student in admins or student == coach
|
||||
except CCXUserValidationException as exp:
|
||||
log.info("%s", exp)
|
||||
errors.append("{0}".format(exp))
|
||||
log.info(u"%s", exp)
|
||||
errors.append(u"{0}".format(exp))
|
||||
continue
|
||||
|
||||
if CourseEnrollment.objects.is_course_full(ccx_course_overview) and not must_enroll:
|
||||
error = _(u'The course is full: the limit is {max_student_enrollments_allowed}').format(
|
||||
max_student_enrollments_allowed=ccx_course_overview.max_student_enrollments_allowed)
|
||||
log.info("%s", error)
|
||||
log.info(u"%s", error)
|
||||
errors.append(error)
|
||||
break
|
||||
enroll_email(course_key, email, auto_enroll=True, email_students=email_students, email_params=email_params)
|
||||
@@ -276,8 +276,8 @@ def ccx_students_enrolling_center(action, identifiers, email_students, course_ke
|
||||
try:
|
||||
email, __ = get_valid_student_with_email(identifier)
|
||||
except CCXUserValidationException as exp:
|
||||
log.info("%s", exp)
|
||||
errors.append("{0}".format(exp))
|
||||
log.info(u"%s", exp)
|
||||
errors.append(u"{0}".format(exp))
|
||||
continue
|
||||
unenroll_email(course_key, email, email_students=email_students, email_params=email_params)
|
||||
return errors
|
||||
|
||||
@@ -550,7 +550,8 @@ def ccx_grades_csv(request, course, ccx=None):
|
||||
}
|
||||
|
||||
row_percents = [percents.get(label, 0.0) for label in header]
|
||||
rows.append([student.id, student.email, student.username,
|
||||
rows.append([student.id, student.email.encode('utf-8'),
|
||||
student.username.encode('utf-8'),
|
||||
course_grade.percent] + row_percents)
|
||||
|
||||
buf = StringIO()
|
||||
|
||||
Reference in New Issue
Block a user