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
fea6feb0
Commit
fea6feb0
authored
Jan 16, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip whitespace off of registration demographics before validation
parent
a7567768
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
common/djangoapps/student/views.py
+10
-3
No files found.
common/djangoapps/student/views.py
View file @
fea6feb0
...
...
@@ -678,11 +678,18 @@ def create_exam_registration(request, post_override=None):
username
=
post_vars
[
'username'
]
user
=
User
.
objects
.
get
(
username
=
username
)
course_id
=
post_vars
[
'course_id'
]
course
=
(
course_from_id
(
course_id
))
# assume it will be found....
course
=
course_from_id
(
course_id
)
# assume it will be found....
# make sure that any demographic data values received from the page have been stripped.
# Whitespace is not an acceptable response for any of these values
demographic_data
=
{}
for
fieldname
in
TestCenterUser
.
user_provided_fields
():
if
fieldname
in
post_vars
:
demographic_data
[
fieldname
]
=
(
post_vars
[
fieldname
])
.
strip
()
try
:
testcenter_user
=
TestCenterUser
.
objects
.
get
(
user
=
user
)
needs_updating
=
testcenter_user
.
needs_update
(
post_vars
)
needs_updating
=
testcenter_user
.
needs_update
(
demographic_data
)
log
.
info
(
"User {0} enrolled in course {1} {2}updating demographic info for exam registration"
.
format
(
user
.
username
,
course_id
,
""
if
needs_updating
else
"not "
))
except
TestCenterUser
.
DoesNotExist
:
# do additional initialization here:
...
...
@@ -694,7 +701,7 @@ def create_exam_registration(request, post_override=None):
if
needs_updating
:
# first perform validation on the user information
# using a Django Form.
form
=
TestCenterUserForm
(
instance
=
testcenter_user
,
data
=
post_vars
)
form
=
TestCenterUserForm
(
instance
=
testcenter_user
,
data
=
demographic_data
)
if
form
.
is_valid
():
form
.
update_and_save
()
else
:
...
...
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