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
OpenEdx
edx-platform
Commits
424cc110
Commit
424cc110
authored
Jan 28, 2014
by
Bertrand Marron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add create_account server events to tracking log
parent
cb7f63d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
1 deletions
+49
-1
common/djangoapps/student/views.py
+49
-1
No files found.
common/djangoapps/student/views.py
View file @
424cc110
...
...
@@ -1120,6 +1120,41 @@ def _do_create_account(post_vars, extended_profile=None):
return
(
user
,
profile
,
registration
)
def
make_registration_track_function
(
request
,
post_vars
):
'''
Make a tracking function that logs registration events.
'''
import
track
fields
=
post_vars
.
copy
()
censored_fields
=
[
'password'
]
unwanted_fields
=
[
'csrfmiddlewaretoken'
]
for
field
in
censored_fields
:
if
field
in
fields
:
fields
[
field
]
=
'********'
for
field
in
unwanted_fields
:
if
field
in
fields
:
del
fields
[
field
]
def
function
(
success
,
js_data
=
None
):
event_info
=
{
'fields'
:
fields
}
if
success
:
event_type
=
'edx.user.creation.succeeded'
else
:
event_type
=
'edx.user.creation.failed'
if
js_data
:
event_info
[
'error_message'
]
=
js_data
[
'value'
]
if
'field'
in
js_data
:
event_info
[
'error_field'
]
=
js_data
[
'field'
]
return
track
.
views
.
server_track
(
request
,
event_type
,
event_info
,
page
=
'register'
)
return
function
@ensure_csrf_cookie
def
create_account
(
request
,
post_override
=
None
):
# pylint: disable-msg=too-many-statements
"""
...
...
@@ -1140,6 +1175,8 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
post_vars
=
dict
(
post_vars
.
items
())
post_vars
.
update
({
'password'
:
pipeline
.
make_random_password
()})
track_registration
=
make_registration_track_function
(
request
,
post_vars
)
# if doing signup for an external authorization, then get email, password, name from the eamap
# don't use the ones from the form, since the user could have hacked those
# unless originally we didn't get a valid email or name from the external auth
...
...
@@ -1165,12 +1202,14 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
if
a
not
in
post_vars
:
js
[
'value'
]
=
_
(
"Error (401 {field}). E-mail us."
)
.
format
(
field
=
a
)
js
[
'field'
]
=
a
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
if
extra_fields
.
get
(
'honor_code'
,
'required'
)
==
'required'
and
\
post_vars
.
get
(
'honor_code'
,
'false'
)
!=
u'true'
:
js
[
'value'
]
=
_
(
"To enroll, you must follow the honor code."
)
.
format
(
field
=
a
)
js
[
'field'
]
=
'honor_code'
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
# Can't have terms of service for certain SHIB users, like at Stanford
...
...
@@ -1187,6 +1226,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
if
post_vars
.
get
(
'terms_of_service'
,
'false'
)
!=
u'true'
:
js
[
'value'
]
=
_
(
"You must accept the terms of service."
)
.
format
(
field
=
a
)
js
[
'field'
]
=
'terms_of_service'
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
# Confirm appropriate fields are there.
...
...
@@ -1230,6 +1270,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
js
[
'value'
]
=
_
(
'You are missing one or more required fields'
)
js
[
'field'
]
=
field_name
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
max_length
=
75
...
...
@@ -1243,6 +1284,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
}
js
[
'value'
]
=
error_str
[
field_name
]
js
[
'field'
]
=
field_name
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
try
:
...
...
@@ -1250,6 +1292,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
except
ValidationError
:
js
[
'value'
]
=
_
(
"Valid e-mail is required."
)
.
format
(
field
=
a
)
js
[
'field'
]
=
'email'
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
try
:
...
...
@@ -1257,6 +1300,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
except
ValidationError
:
js
[
'value'
]
=
_
(
"Username should only consist of A-Z and 0-9, with no spaces."
)
.
format
(
field
=
a
)
js
[
'field'
]
=
'username'
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
# enforce password complexity as an optional feature
...
...
@@ -1271,6 +1315,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
except
ValidationError
,
err
:
js
[
'value'
]
=
_
(
'Password: '
)
+
'; '
.
join
(
err
.
messages
)
js
[
'field'
]
=
'password'
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
# allow microsites to define 'extended profile fields' which are
...
...
@@ -1297,8 +1342,11 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
try
:
with
transaction
.
commit_on_success
():
ret
=
_do_create_account
(
post_vars
,
extended_profile
)
track_registration
(
True
)
except
AccountValidationError
as
e
:
return
JsonResponse
({
'success'
:
False
,
'value'
:
e
.
message
,
'field'
:
e
.
field
},
status
=
400
)
js
=
{
'success'
:
False
,
'value'
:
e
.
message
,
'field'
:
e
.
field
}
track_registration
(
False
,
js
)
return
JsonResponse
(
js
,
status
=
400
)
(
user
,
profile
,
registration
)
=
ret
...
...
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