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
71b585bb
Commit
71b585bb
authored
Nov 17, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move unique_id_for_user into student/models.py
parent
61ddec46
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
common/djangoapps/student/models.py
+15
-0
common/djangoapps/student/tests.py
+4
-2
common/djangoapps/student/views.py
+1
-5
No files found.
common/djangoapps/student/models.py
View file @
71b585bb
...
@@ -36,10 +36,12 @@ file and check it in at the same time as your model changes. To do that,
...
@@ -36,10 +36,12 @@ file and check it in at the same time as your model changes. To do that,
3. Add the migration file created in mitx/common/djangoapps/student/migrations/
3. Add the migration file created in mitx/common/djangoapps/student/migrations/
"""
"""
from
datetime
import
datetime
from
datetime
import
datetime
from
hashlib
import
sha1
import
json
import
json
import
logging
import
logging
import
uuid
import
uuid
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.db
import
models
from
django.db
import
models
...
@@ -191,6 +193,19 @@ class TestCenterUser(models.Model):
...
@@ -191,6 +193,19 @@ class TestCenterUser(models.Model):
def
email
(
self
):
def
email
(
self
):
return
self
.
user
.
email
return
self
.
user
.
email
def
unique_id_for_user
(
user
):
"""
Return a unique id for a user, suitable for inserting into
e.g. personalized survey links.
Currently happens to be implemented as a sha1 hash of the username
(and thus assumes that usernames don't change).
"""
return
sha1
(
user
.
username
)
.
hexdigest
()
## TODO: Should be renamed to generic UserGroup, and possibly
## TODO: Should be renamed to generic UserGroup, and possibly
# Given an optional field for type of group
# Given an optional field for type of group
class
UserTestGroup
(
models
.
Model
):
class
UserTestGroup
(
models
.
Model
):
...
...
common/djangoapps/student/tests.py
View file @
71b585bb
...
@@ -12,8 +12,10 @@ from django.test import TestCase
...
@@ -12,8 +12,10 @@ from django.test import TestCase
from
mock
import
patch
,
Mock
from
mock
import
patch
,
Mock
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
.models
import
User
,
UserProfile
,
CourseEnrollment
,
replicate_user
,
USER_FIELDS_TO_COPY
from
.models
import
(
User
,
UserProfile
,
CourseEnrollment
,
from
.views
import
process_survey_link
,
_cert_info
,
unique_id_for_user
replicate_user
,
USER_FIELDS_TO_COPY
,
unique_id_for_user
)
from
.views
import
process_survey_link
,
_cert_info
COURSE_1
=
'edX/toy/2012_Fall'
COURSE_1
=
'edX/toy/2012_Fall'
COURSE_2
=
'edx/full/6.002_Spring_2012'
COURSE_2
=
'edx/full/6.002_Spring_2012'
...
...
common/djangoapps/student/views.py
View file @
71b585bb
...
@@ -28,7 +28,7 @@ from django.core.cache import cache
...
@@ -28,7 +28,7 @@ from django.core.cache import cache
from
django_future.csrf
import
ensure_csrf_cookie
,
csrf_exempt
from
django_future.csrf
import
ensure_csrf_cookie
,
csrf_exempt
from
student.models
import
(
Registration
,
UserProfile
,
from
student.models
import
(
Registration
,
UserProfile
,
PendingNameChange
,
PendingEmailChange
,
PendingNameChange
,
PendingEmailChange
,
CourseEnrollment
)
CourseEnrollment
,
unique_id_for_user
)
from
certificates.models
import
CertificateStatuses
,
certificate_status_for_student
from
certificates.models
import
CertificateStatuses
,
certificate_status_for_student
...
@@ -39,7 +39,6 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
...
@@ -39,7 +39,6 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
from
datetime
import
date
from
datetime
import
date
from
collections
import
namedtuple
from
collections
import
namedtuple
from
hashlib
import
sha1
from
courseware.courses
import
get_courses_by_university
from
courseware.courses
import
get_courses_by_university
from
courseware.access
import
has_access
from
courseware.access
import
has_access
...
@@ -129,9 +128,6 @@ def press(request):
...
@@ -129,9 +128,6 @@ def press(request):
return
render_to_response
(
'static_templates/press.html'
,
{
'articles'
:
articles
})
return
render_to_response
(
'static_templates/press.html'
,
{
'articles'
:
articles
})
def
unique_id_for_user
(
user
):
return
sha1
(
user
.
username
)
.
hexdigest
()
def
process_survey_link
(
survey_link
,
user
):
def
process_survey_link
(
survey_link
,
user
):
"""
"""
If {UNIQUE_ID} appears in the link, replace it with a unique id for the user.
If {UNIQUE_ID} appears in the link, replace it with a unique id for the user.
...
...
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