edx-platform
edx-platform copied to clipboard
LMS bug: un-enroll from courses with unicode name or organization
when trying to un-enroll from those courses the following code renders inside the modal box:
UnicodeEncodeError at /change_enrollment 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128) Request Method: POST Request URL: http://localhost:8000/change_enrollment Django Version: 1.4.8 Python Executable: /edx/app/edxapp/venvs/edxapp/bin/python Python Version: 2.7.3 Python Path: ['/edx/app/edxapp/edx-platform', '/edx/app/edxapp/venvs/edxapp/src/django-staticfiles', '/edx/app/edxapp/venvs/edxapp/src/django-pipeline', '/edx/app/edxapp/venvs/edxapp/src/django-wiki', '/edx/app/edxapp/venvs/edxapp/src/lettuce', '/edx/app/edxapp/venvs/edxapp/src/pystache-custom', '/edx/app/edxapp/venvs/edxapp/src/zendesk', '/edx/app/edxapp/venvs/edxapp/src/xblock', '/edx/app/edxapp/venvs/edxapp/src/codejail', '/edx/app/edxapp/venvs/edxapp/src/diff-cover', '/edx/app/edxapp/venvs/edxapp/src/js-test-tool', '/edx/app/edxapp/venvs/edxapp/src/django-waffle', '/edx/app/edxapp/venvs/edxapp/src/event-tracking', '/edx/app/edxapp/edx-platform/common/lib/calc', '/edx/app/edxapp/edx-platform/common/lib/capa', '/edx/app/edxapp/edx-platform/common/lib/chem', '/edx/app/edxapp/edx-platform/common/lib/sandbox-packages', '/edx/app/edxapp/edx-platform/common/lib/symmath', '/edx/app/edxapp/edx-platform/common/lib/xmodule', '/edx/app/edxapp/venvs/edxapp/src/bok-choy', '/edx/app/edxapp/venvs/edxapp/lib/python2.7', '/edx/app/edxapp/venvs/edxapp/lib/python2.7/plat-linux2', '/edx/app/edxapp/venvs/edxapp/lib/python2.7/lib-tk', '/edx/app/edxapp/venvs/edxapp/lib/python2.7/lib-old', '/edx/app/edxapp/venvs/edxapp/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages', '/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/newrelic-2.4.0.4', '/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', '/edx/app/edxapp/venvs/edxapp/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', path(u'/edx/app/edxapp/edx-platform'), path(u'/edx/app/edxapp/edx-platform/lms/djangoapps'), path(u'/edx/app/edxapp/edx-platform/common/djangoapps'), path(u'/edx/app/edxapp/edx-platform/common/lib')] Server time: ثلاثاء, 21 يناير 2014 06:24:23 +0200
I solved this problem by modifying the change_enrollment code inside views.py fil using unicode strings like so;
elif action == "unenroll":
if not CourseEnrollment.is_enrolled(user, course_id):
return HttpResponseBadRequest(_("You are not enrolled in this course"))
CourseEnrollment.unenroll(user, course_id)
org, course_num, run = course_id.split("/")
dog_stats_api.increment(
"common.student.unenrollment",
tags=[u"org:{0}".format(org),
u"course:{0}".format(course_num),
u"run:{0}".format(run)]
)
return HttpResponse()
else:
return HttpResponseBadRequest(_("Enrollment action is invalid"))
sorry I cannot submit this as a PR right now. hope it can help
These changes are already in master, so it looks like this issue has been fixed. Feel free to reopen it if you're still having trouble.