Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
fbd9cc13
Commit
fbd9cc13
authored
Sep 25, 2014
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5386 from open-craft/fix-anonymous-ids-unicode
Fix UnicodeError with anonymous student IDs
parents
0ed3a95d
8e326722
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletions
+10
-1
common/djangoapps/student/models.py
+1
-1
common/djangoapps/student/tests/tests.py
+9
-0
No files found.
common/djangoapps/student/models.py
View file @
fbd9cc13
...
@@ -102,7 +102,7 @@ def anonymous_id_for_user(user, course_id, save=True):
...
@@ -102,7 +102,7 @@ def anonymous_id_for_user(user, course_id, save=True):
hasher
.
update
(
settings
.
SECRET_KEY
)
hasher
.
update
(
settings
.
SECRET_KEY
)
hasher
.
update
(
unicode
(
user
.
id
))
hasher
.
update
(
unicode
(
user
.
id
))
if
course_id
:
if
course_id
:
hasher
.
update
(
course_id
.
to_deprecated_string
())
hasher
.
update
(
course_id
.
to_deprecated_string
()
.
encode
(
'utf-8'
)
)
digest
=
hasher
.
hexdigest
()
digest
=
hasher
.
hexdigest
()
if
not
hasattr
(
user
,
'_anonymous_id'
):
if
not
hasattr
(
user
,
'_anonymous_id'
):
...
...
common/djangoapps/student/tests/tests.py
View file @
fbd9cc13
# -*- coding: utf-8 -*-
"""
"""
This file demonstrates writing tests using the unittest module. These will pass
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
when you run "manage.py test".
...
@@ -736,3 +737,11 @@ class AnonymousLookupTable(TestCase):
...
@@ -736,3 +737,11 @@ class AnonymousLookupTable(TestCase):
real_user
=
user_by_anonymous_id
(
anonymous_id
)
real_user
=
user_by_anonymous_id
(
anonymous_id
)
self
.
assertEqual
(
self
.
user
,
real_user
)
self
.
assertEqual
(
self
.
user
,
real_user
)
self
.
assertEqual
(
anonymous_id
,
anonymous_id_for_user
(
self
.
user
,
self
.
course
.
id
,
save
=
False
))
self
.
assertEqual
(
anonymous_id
,
anonymous_id_for_user
(
self
.
user
,
self
.
course
.
id
,
save
=
False
))
def
test_roundtrip_with_unicode_course_id
(
self
):
course2
=
CourseFactory
.
create
(
org
=
self
.
COURSE_ORG
,
display_name
=
u"Omega Course Ω"
,
number
=
self
.
COURSE_SLUG
)
CourseEnrollment
.
enroll
(
self
.
user
,
course2
.
id
)
anonymous_id
=
anonymous_id_for_user
(
self
.
user
,
course2
.
id
)
real_user
=
user_by_anonymous_id
(
anonymous_id
)
self
.
assertEqual
(
self
.
user
,
real_user
)
self
.
assertEqual
(
anonymous_id
,
anonymous_id_for_user
(
self
.
user
,
course2
.
id
,
save
=
False
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment