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
f7d002e6
Commit
f7d002e6
authored
May 31, 2016
by
Peter Fogg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change user attribute for cookies to a constant value.
parent
f64bf4c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
common/djangoapps/student/tests/test_create_account.py
+3
-2
common/djangoapps/student/views.py
+3
-1
No files found.
common/djangoapps/student/tests/test_create_account.py
View file @
f7d002e6
...
...
@@ -20,6 +20,7 @@ from edxmako.tests import mako_middleware_process_request
from
external_auth.models
import
ExternalAuthMap
import
student
from
student.models
import
UserAttribute
from
student.views
import
REGISTRATION_AFFILIATE_ID
TEST_CS_URL
=
'https://comments.service.test:123/'
...
...
@@ -288,14 +289,14 @@ class TestCreateAccount(TestCase):
affiliate_id
=
'test-partner'
self
.
client
.
cookies
[
settings
.
AFFILIATE_COOKIE_NAME
]
=
affiliate_id
user
=
self
.
create_account_and_fetch_profile
()
.
user
self
.
assertEqual
(
UserAttribute
.
get_user_attribute
(
user
,
settings
.
AFFILIATE_COOKIE_NAME
),
affiliate_id
)
self
.
assertEqual
(
UserAttribute
.
get_user_attribute
(
user
,
REGISTRATION_AFFILIATE_ID
),
affiliate_id
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_no_referral
(
self
):
"""Verify that no referral is recorded when a cookie is not present."""
self
.
assertIsNone
(
self
.
client
.
cookies
.
get
(
settings
.
AFFILIATE_COOKIE_NAME
))
# pylint: disable=no-member
user
=
self
.
create_account_and_fetch_profile
()
.
user
self
.
assertIsNone
(
UserAttribute
.
get_user_attribute
(
user
,
settings
.
AFFILIATE_COOKIE_NAME
))
self
.
assertIsNone
(
UserAttribute
.
get_user_attribute
(
user
,
REGISTRATION_AFFILIATE_ID
))
@ddt.ddt
...
...
common/djangoapps/student/views.py
View file @
f7d002e6
...
...
@@ -133,6 +133,8 @@ log = logging.getLogger("edx.student")
AUDIT_LOG
=
logging
.
getLogger
(
"audit"
)
ReverifyInfo
=
namedtuple
(
'ReverifyInfo'
,
'course_id course_name course_number date status display'
)
# pylint: disable=invalid-name
SETTING_CHANGE_INITIATED
=
'edx.user.settings.change_initiated'
# Used as the name of the user attribute for tracking affiliate registrations
REGISTRATION_AFFILIATE_ID
=
'registration_affiliate_id'
# Disable this warning because it doesn't make sense to completely refactor tests to appease Pylint
# pylint: disable=logging-format-interpolation
...
...
@@ -1861,7 +1863,7 @@ def _record_registration_attribution(request, user):
"""
affiliate_id
=
request
.
COOKIES
.
get
(
settings
.
AFFILIATE_COOKIE_NAME
)
if
user
is
not
None
and
affiliate_id
is
not
None
:
UserAttribute
.
set_user_attribute
(
user
,
settings
.
AFFILIATE_COOKIE_NAME
,
affiliate_id
)
UserAttribute
.
set_user_attribute
(
user
,
REGISTRATION_AFFILIATE_ID
,
affiliate_id
)
@csrf_exempt
...
...
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