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
9d81a8be
Commit
9d81a8be
authored
Jul 22, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #256 from MITx/dormsbee/change_reg_fields
Dormsbee/change reg fields
parents
06c2d1f1
074fc243
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
58 deletions
+129
-58
common/djangoapps/student/migrations/0019_create_approved_demographic_fields_fall_2012.py
+69
-13
common/djangoapps/student/models.py
+33
-12
common/djangoapps/student/views.py
+10
-7
lms/djangoapps/student/migrations/0012_auto__chg_field_userprofile_location.py
+0
-0
lms/static/sass/shared/_modal.scss
+1
-1
lms/templates/signup_modal.html
+16
-25
No files found.
lms/djangoapps/student/migrations/0011_auto__chg_field_userprofile_country
.py
→
common/djangoapps/student/migrations/0019_create_approved_demographic_fields_fall_2012
.py
View file @
9d81a8be
...
@@ -8,14 +8,70 @@ from django.db import models
...
@@ -8,14 +8,70 @@ from django.db import models
class
Migration
(
SchemaMigration
):
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
def
forwards
(
self
,
orm
):
# Deleting field 'UserProfile.occupation'
db
.
delete_column
(
'auth_userprofile'
,
'occupation'
)
# Deleting field 'UserProfile.telephone_number'
db
.
delete_column
(
'auth_userprofile'
,
'telephone_number'
)
# Deleting field 'UserProfile.date_of_birth'
db
.
delete_column
(
'auth_userprofile'
,
'date_of_birth'
)
# Deleting field 'UserProfile.country'
db
.
delete_column
(
'auth_userprofile'
,
'country'
)
# Adding field 'UserProfile.year_of_birth'
db
.
add_column
(
'auth_userprofile'
,
'year_of_birth'
,
self
.
gf
(
'django.db.models.fields.IntegerField'
)(
db_index
=
True
,
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Adding field 'UserProfile.level_of_education'
db
.
add_column
(
'auth_userprofile'
,
'level_of_education'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
db_index
=
True
,
max_length
=
6
,
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Adding field 'UserProfile.goals'
db
.
add_column
(
'auth_userprofile'
,
'goals'
,
self
.
gf
(
'django.db.models.fields.TextField'
)(
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Adding index on 'UserProfile', fields ['gender']
db
.
create_index
(
'auth_userprofile'
,
[
'gender'
])
# Changing field 'UserProfile.country'
db
.
alter_column
(
'auth_userprofile'
,
'country'
,
self
.
gf
(
'django_countries.fields.CountryField'
)(
max_length
=
2
,
null
=
True
))
def
backwards
(
self
,
orm
):
def
backwards
(
self
,
orm
):
# Removing index on 'UserProfile', fields ['gender']
db
.
delete_index
(
'auth_userprofile'
,
[
'gender'
])
# Adding field 'UserProfile.occupation'
db
.
add_column
(
'auth_userprofile'
,
'occupation'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
255
,
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Adding field 'UserProfile.telephone_number'
db
.
add_column
(
'auth_userprofile'
,
'telephone_number'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
25
,
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Adding field 'UserProfile.date_of_birth'
db
.
add_column
(
'auth_userprofile'
,
'date_of_birth'
,
self
.
gf
(
'django.db.models.fields.DateField'
)(
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Adding field 'UserProfile.country'
db
.
add_column
(
'auth_userprofile'
,
'country'
,
self
.
gf
(
'django_countries.fields.CountryField'
)(
max_length
=
2
,
null
=
True
,
blank
=
True
),
keep_default
=
False
)
# Deleting field 'UserProfile.year_of_birth'
db
.
delete_column
(
'auth_userprofile'
,
'year_of_birth'
)
# Deleting field 'UserProfile.level_of_education'
db
.
delete_column
(
'auth_userprofile'
,
'level_of_education'
)
# Deleting field 'UserProfile.goals'
db
.
delete_column
(
'auth_userprofile'
,
'goals'
)
# Changing field 'UserProfile.country'
db
.
alter_column
(
'auth_userprofile'
,
'country'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
255
,
null
=
True
))
models
=
{
models
=
{
'auth.group'
:
{
'auth.group'
:
{
...
@@ -80,8 +136,9 @@ class Migration(SchemaMigration):
...
@@ -80,8 +136,9 @@ class Migration(SchemaMigration):
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
})
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
})
},
},
'student.courseenrollment'
:
{
'student.courseenrollment'
:
{
'Meta'
:
{
'object_name'
:
'CourseEnrollment'
},
'Meta'
:
{
'unique_together'
:
"(('user', 'course_id'),)"
,
'object_name'
:
'CourseEnrollment'
},
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
}),
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'created'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'null'
:
'True'
,
'db_index'
:
'True'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'user'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
"orm['auth.User']"
})
'user'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
"orm['auth.User']"
})
},
},
...
@@ -107,19 +164,18 @@ class Migration(SchemaMigration):
...
@@ -107,19 +164,18 @@ class Migration(SchemaMigration):
},
},
'student.userprofile'
:
{
'student.userprofile'
:
{
'Meta'
:
{
'object_name'
:
'UserProfile'
,
'db_table'
:
"'auth_userprofile'"
},
'Meta'
:
{
'object_name'
:
'UserProfile'
,
'db_table'
:
"'auth_userprofile'"
},
'country'
:
(
'django_countries.fields.CountryField'
,
[],
{
'max_length'
:
'2'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'courseware'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'course.xml'"
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'courseware'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'course.xml'"
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'
date_of_birth'
:
(
'django.db.models.fields.DateField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
'
gender'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'6'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'g
ender'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'6'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'g
oals'
:
(
'django.db.models.fields.TextField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'language'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'language'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'level_of_education'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'6'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'location'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'location'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'mailing_address'
:
(
'django.db.models.fields.TextField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
'mailing_address'
:
(
'django.db.models.fields.TextField'
,
[],
{
'null'
:
'True'
,
'blank'
:
'True'
}),
'meta'
:
(
'django.db.models.fields.
CharField'
,
[],
{
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'meta'
:
(
'django.db.models.fields.
TextField'
,
[],
{
'blank'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'db_index'
:
'True'
,
'max_length'
:
'255'
,
'blank'
:
'True'
}),
'occupation'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'user'
:
(
'django.db.models.fields.related.OneToOneField'
,
[],
{
'related_name'
:
"'profile'"
,
'unique'
:
'True'
,
'to'
:
"orm['auth.User']"
}),
'telephone_number'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'25'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'year_of_birth'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'db_index'
:
'True'
,
'null'
:
'True'
,
'blank'
:
'True'
})
'user'
:
(
'django.db.models.fields.related.OneToOneField'
,
[],
{
'related_name'
:
"'profile'"
,
'unique'
:
'True'
,
'to'
:
"orm['auth.User']"
})
},
},
'student.usertestgroup'
:
{
'student.usertestgroup'
:
{
'Meta'
:
{
'object_name'
:
'UserTestGroup'
},
'Meta'
:
{
'object_name'
:
'UserTestGroup'
},
...
...
common/djangoapps/student/models.py
View file @
9d81a8be
...
@@ -5,14 +5,15 @@ If you make changes to this model, be sure to create an appropriate migration
...
@@ -5,14 +5,15 @@ 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,
file and check it in at the same time as your model changes. To do that,
1. Go to the mitx dir
1. Go to the mitx dir
2.
./manage.py schemamigration user --auto
description_of_your_change
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
urseware
/migrations/
3. Add the migration file created in mitx/co
mmon/djangoapps/student
/migrations/
"""
"""
from
datetime
import
datetime
import
json
import
uuid
import
uuid
from
django.db
import
models
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
import
json
from
django_countries
import
CountryField
from
django_countries
import
CountryField
#from cache_toolbox import cache_model, cache_relation
#from cache_toolbox import cache_model, cache_relation
...
@@ -21,23 +22,43 @@ class UserProfile(models.Model):
...
@@ -21,23 +22,43 @@ class UserProfile(models.Model):
class
Meta
:
class
Meta
:
db_table
=
"auth_userprofile"
db_table
=
"auth_userprofile"
GENDER_CHOICES
=
((
'm'
,
'Male'
),
(
'f'
,
'Female'
),
(
'o'
,
'Other'
))
## CRITICAL TODO/SECURITY
## CRITICAL TODO/SECURITY
# Sanitize all fields.
# Sanitize all fields.
# This is not visible to other users, but could introduce holes later
# This is not visible to other users, but could introduce holes later
user
=
models
.
OneToOneField
(
User
,
unique
=
True
,
db_index
=
True
,
related_name
=
'profile'
)
user
=
models
.
OneToOneField
(
User
,
unique
=
True
,
db_index
=
True
,
related_name
=
'profile'
)
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
db_index
=
True
)
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
meta
=
models
.
TextField
(
blank
=
True
)
# JSON dictionary for future expansion
courseware
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
default
=
'course.xml'
)
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
this_year
=
datetime
.
now
()
.
year
VALID_YEARS
=
range
(
this_year
,
this_year
-
120
,
-
1
)
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'
,
"Bachelor's 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
)
mailing_address
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
country
=
CountryField
(
blank
=
True
,
null
=
True
)
goals
=
models
.
TextField
(
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
)
def
get_meta
(
self
):
def
get_meta
(
self
):
js_str
=
self
.
meta
js_str
=
self
.
meta
...
...
common/djangoapps/student/views.py
View file @
9d81a8be
...
@@ -306,17 +306,20 @@ def create_account(request, post_override=None):
...
@@ -306,17 +306,20 @@ def create_account(request, post_override=None):
up
=
UserProfile
(
user
=
u
)
up
=
UserProfile
(
user
=
u
)
up
.
name
=
post_vars
[
'name'
]
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
.
gender
=
post_vars
[
'gender'
]
up
.
mailing_address
=
post_vars
[
'mailing_address'
]
up
.
mailing_address
=
post_vars
[
'mailing_address'
]
up
.
goals
=
post_vars
[
'goals'
]
date_fields
=
[
'date_of_birth__year'
,
'date_of_birth__month'
,
'date_of_birth__day'
]
try
:
if
all
(
len
(
post_vars
[
field
])
>
0
for
field
in
date_fields
):
up
.
year_of_birth
=
int
(
post_vars
[
'year_of_birth'
])
up
.
date_of_birth
=
date
(
int
(
post_vars
[
'date_of_birth__year'
]),
except
ValueError
:
int
(
post_vars
[
'date_of_birth__month'
]),
up
.
year_of_birth
=
None
# If they give us garbage, just ignore it instead
int
(
post_vars
[
'date_of_birth__day'
]))
# of asking them to put an integer.
try
:
up
.
save
()
up
.
save
()
except
Exception
:
log
.
exception
(
"UserProfile creation failed for user {0}."
.
format
(
u
.
id
))
d
=
{
'name'
:
post_vars
[
'name'
],
d
=
{
'name'
:
post_vars
[
'name'
],
'key'
:
r
.
activation_key
,
'key'
:
r
.
activation_key
,
...
...
lms/djangoapps/student/migrations/0012_auto__chg_field_userprofile_location.py
deleted
100644 → 0
View file @
06c2d1f1
This diff is collapsed.
Click to expand it.
lms/static/sass/shared/_modal.scss
View file @
9d81a8be
...
@@ -210,7 +210,7 @@
...
@@ -210,7 +210,7 @@
.citizenship
,
.gender
{
.citizenship
,
.gender
{
float
:
left
;
float
:
left
;
width
:
flex-grid
(
6
);
width
:
flex-grid
(
4
);
}
}
.citizenship
{
.citizenship
{
...
...
lms/templates/signup_modal.html
View file @
9d81a8be
...
@@ -27,18 +27,16 @@
...
@@ -27,18 +27,16 @@
<input
name=
"username"
type=
"text"
placeholder=
"Public Username*"
>
<input
name=
"username"
type=
"text"
placeholder=
"Public Username*"
>
<label>
Full Name
</label>
<label>
Full Name
</label>
<input
name=
"name"
type=
"text"
placeholder=
"Full Name*"
>
<input
name=
"name"
type=
"text"
placeholder=
"Full Name*"
>
<label>
Mailing address
</label>
<textarea
name=
"mailing_address"
placeholder=
"Mailing address"
></textarea>
</div>
</div>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<section
class=
"citizenship"
>
<section
class=
"citizenship"
>
<label>
Country
</label>
<label>
Ed. completed
</label>
<div
class=
"input-wrapper"
>
<div
class=
"input-wrapper"
>
<select
name=
"
country
"
>
<select
name=
"
level_of_education
"
>
<option
value=
""
>
--
</option>
<option
value=
""
>
--
</option>
%for co
untry_code, country_name in COUNTRI
ES:
%for co
de, ed_level in UserProfile.LEVEL_OF_EDUCATION_CHOIC
ES:
<option
value=
"${co
untry_code}"
>
${country_name
}
</option>
<option
value=
"${co
de}"
>
${ed_level
}
</option>
%endfor
%endfor
</select>
</select>
</div>
</div>
...
@@ -56,31 +54,24 @@
...
@@ -56,31 +54,24 @@
</div>
</div>
</section>
</section>
<section
class=
"
date-of-birth
"
>
<section
class=
"
gender
"
>
<label>
Date
of birth
</label>
<label>
Year
of birth
</label>
<div
class=
"input-wrapper"
>
<div
class=
"input-wrapper"
>
<select
name=
'date_of_birth__month'
>
<select
name=
"year_of_birth"
>
<option
value=
""
>
month
</option>
<option
value=
""
>
--
</option>
%for month in range(1,13):
%for year in UserProfile.VALID_YEARS:
<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>
<option
value=
"${year}"
>
${year}
</option>
%endfor
%endfor
</select>
</select>
##
<input
name=
"year_of_birth"
type=
"text"
placeholder=
"Year of birth"
>
</div>
</div>
</section>
</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>
<div
class=
"input-group"
>
<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