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
e3a8033d
Commit
e3a8033d
authored
Jul 22, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change over to new reg fields (styling still broken)
parent
42a639c8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
48 deletions
+54
-48
common/djangoapps/student/migrations/0016_create_approved_demographic_fields_fall_2012.py
+0
-0
common/djangoapps/student/models.py
+29
-11
common/djangoapps/student/views.py
+12
-9
lms/templates/signup_modal.html
+13
-28
No files found.
common/djangoapps/student/migrations/0016_create_approved_demographic_fields_fall_2012.py
0 → 100644
View file @
e3a8033d
This diff is collapsed.
Click to expand it.
common/djangoapps/student/models.py
View file @
e3a8033d
...
...
@@ -5,8 +5,8 @@ If you make changes to this model, be sure to create an appropriate migration
file and check it in at the same time as your model changes. To do that,
1. Go to the mitx dir
2.
./manage.py schemamigration user --auto
description_of_your_change
3. Add the migration file created in mitx/co
urseware
/migrations/
2.
django-admin.py schemamigration student --auto --settings=lms.envs.dev --pythonpath=.
description_of_your_change
3. Add the migration file created in mitx/co
mmon/djangoapps/student
/migrations/
"""
import
uuid
...
...
@@ -21,23 +21,41 @@ class UserProfile(models.Model):
class
Meta
:
db_table
=
"auth_userprofile"
GENDER_CHOICES
=
((
'm'
,
'Male'
),
(
'f'
,
'Female'
),
(
'o'
,
'Other'
))
## CRITICAL TODO/SECURITY
# Sanitize all fields.
# This is not visible to other users, but could introduce holes later
user
=
models
.
OneToOneField
(
User
,
unique
=
True
,
db_index
=
True
,
related_name
=
'profile'
)
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
db_index
=
True
)
language
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
db_index
=
True
)
location
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
db_index
=
True
)
# TODO: What are we doing with this?
meta
=
models
.
TextField
(
blank
=
True
)
# JSON dictionary for future expansion
courseware
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
default
=
'course.xml'
)
gender
=
models
.
CharField
(
blank
=
True
,
null
=
True
,
max_length
=
6
,
choices
=
GENDER_CHOICES
)
date_of_birth
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
# Location is no longer used, but is held here for backwards compatibility
# for users imported from our first class.
language
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
db_index
=
True
)
location
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
db_index
=
True
)
# Optional demographic data we started capturing from Fall 2012
year_of_birth
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
db_index
=
True
)
GENDER_CHOICES
=
((
'm'
,
'Male'
),
(
'f'
,
'Female'
),
(
'o'
,
'Other'
))
gender
=
models
.
CharField
(
blank
=
True
,
null
=
True
,
max_length
=
6
,
db_index
=
True
,
choices
=
GENDER_CHOICES
)
LEVEL_OF_EDUCATION_CHOICES
=
((
'p_se'
,
'Doctorate in science or engineering'
),
(
'p_oth'
,
'Doctorate in another field'
),
(
'm'
,
"Master's or professional degree"
),
(
'b'
,
"Master's or professional degree"
),
(
'hs'
,
"Secondary/high school"
),
(
'jhs'
,
"Junior secondary/junior high/middle school"
),
(
'el'
,
"Elementary/primary school"
),
(
'none'
,
"None"
),
(
'other'
,
"Other"
))
level_of_education
=
models
.
CharField
(
blank
=
True
,
null
=
True
,
max_length
=
6
,
db_index
=
True
,
choices
=
LEVEL_OF_EDUCATION_CHOICES
)
mailing_address
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
country
=
CountryField
(
blank
=
True
,
null
=
True
)
telephone_number
=
models
.
CharField
(
blank
=
True
,
null
=
True
,
max_length
=
25
)
occupation
=
models
.
CharField
(
blank
=
True
,
null
=
True
,
max_length
=
255
)
goals
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
def
get_meta
(
self
):
js_str
=
self
.
meta
...
...
common/djangoapps/student/views.py
View file @
e3a8033d
...
...
@@ -243,17 +243,20 @@ def create_account(request, post_override=None):
up
=
UserProfile
(
user
=
u
)
up
.
name
=
post_vars
[
'name'
]
up
.
country
=
post_vars
[
'country
'
]
up
.
level_of_education
=
post_vars
[
'level_of_education
'
]
up
.
gender
=
post_vars
[
'gender'
]
up
.
mailing_address
=
post_vars
[
'mailing_address'
]
date_fields
=
[
'date_of_birth__year'
,
'date_of_birth__month'
,
'date_of_birth__day'
]
if
all
(
len
(
post_vars
[
field
])
>
0
for
field
in
date_fields
):
up
.
date_of_birth
=
date
(
int
(
post_vars
[
'date_of_birth__year'
]),
int
(
post_vars
[
'date_of_birth__month'
]),
int
(
post_vars
[
'date_of_birth__day'
]))
up
.
save
()
up
.
goals
=
post_vars
[
'goals'
]
try
:
up
.
year_of_birth
=
int
(
post_vars
[
'year_of_birth'
])
except
ValueError
:
up
.
year_of_birth
=
None
# If they give us garbage, just ignore it instead
# of asking them to put an integer.
try
:
up
.
save
()
except
Exception
:
log
.
exception
(
"UserProfile creation failed for user {0}."
.
format
(
u
.
id
))
d
=
{
'name'
:
post_vars
[
'name'
],
'key'
:
r
.
activation_key
,
...
...
lms/templates/signup_modal.html
View file @
e3a8033d
...
...
@@ -27,18 +27,16 @@
<input
name=
"username"
type=
"text"
placeholder=
"Public Username*"
>
<label>
Full Name
</label>
<input
name=
"name"
type=
"text"
placeholder=
"Full Name*"
>
<label>
Mailing address
</label>
<textarea
name=
"mailing_address"
placeholder=
"Mailing address"
></textarea>
</div>
<div
class=
"input-group"
>
<section
class=
"citizenship"
>
<label>
Country
</label>
<label>
Level of Education
</label>
<div
class=
"input-wrapper"
>
<select
name=
"
country
"
>
<select
name=
"
level_of_education
"
>
<option
value=
""
>
--
</option>
%for co
untry_code, country_name in COUNTRI
ES:
<option
value=
"${co
untry_code}"
>
${country_name
}
</option>
%for co
de, ed_level in UserProfile.LEVEL_OF_EDUCATION_CHOIC
ES:
<option
value=
"${co
de}"
>
${ed_level
}
</option>
%endfor
</select>
</div>
...
...
@@ -56,31 +54,18 @@
</div>
</section>
<section
class=
"
date-of-birth
"
>
<label>
Date
of birth
</label>
<section
class=
"
gender
"
>
<label>
Year
of birth
</label>
<div
class=
"input-wrapper"
>
<select
name=
'date_of_birth__month'
>
<option
value=
""
>
month
</option>
%for month in range(1,13):
<option
value=
"${month}"
>
${month} - ${calendar.month_name[month]}
</option>
%endfor
</select>
<select
name=
'date_of_birth__day'
>
<option
value=
""
>
day
</option>
%for day in range(1,32):
<option
value=
"${day}"
>
${day}
</option>
%endfor
</select>
<select
name=
'date_of_birth__year'
>
<option
value=
""
>
year
</option>
%for year in range(date.today().year,1899,-1):
<option
value=
"${year}"
>
${year}
</option>
%endfor
</select>
<input
name=
"year_of_birth"
type=
"text"
placeholder=
"Year of birth"
>
</div>
</section>
<label>
Mailing address
</label>
<textarea
name=
"mailing_address"
placeholder=
"Mailing address"
></textarea>
<label>
Goals in signing up for edX
</label>
<textarea
name=
"goals"
placeholder=
"Goals in signing up for edX"
></textarea>
</div>
<div
class=
"input-group"
>
...
...
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