Commit e3a8033d by David Ormsbee

Change over to new reg fields (styling still broken)

parent 42a639c8
......@@ -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/courseware/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/common/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
......
......@@ -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,
......
......@@ -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 country_code, country_name in COUNTRIES:
<option value="${country_code}">${country_name}</option>
%for code, ed_level in UserProfile.LEVEL_OF_EDUCATION_CHOICES:
<option value="${code}">${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">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment