Commit 2f96527f by David Ormsbee

Merge pull request #203 from MITx/multicourse-countries-and-other-demographics

Multicourse countries and other demographics
parents 23460730 98ee9fb4
...@@ -13,6 +13,7 @@ import uuid ...@@ -13,6 +13,7 @@ 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 import json
from django_countries import CountryField
#from cache_toolbox import cache_model, cache_relation #from cache_toolbox import cache_model, cache_relation
...@@ -20,7 +21,7 @@ class UserProfile(models.Model): ...@@ -20,7 +21,7 @@ class UserProfile(models.Model):
class Meta: class Meta:
db_table = "auth_userprofile" db_table = "auth_userprofile"
GENDER_CHOICES = (('male', 'Male'), ('female', 'Female'), ('other', 'Other')) GENDER_CHOICES = (('m', 'Male'), ('f', 'Female'), ('o', 'Other'))
## CRITICAL TODO/SECURITY ## CRITICAL TODO/SECURITY
# Sanitize all fields. # Sanitize all fields.
...@@ -34,7 +35,7 @@ class UserProfile(models.Model): ...@@ -34,7 +35,7 @@ class UserProfile(models.Model):
gender = models.CharField(blank=True, null=True, max_length=6, choices=GENDER_CHOICES) gender = models.CharField(blank=True, null=True, max_length=6, choices=GENDER_CHOICES)
date_of_birth = models.DateField(blank=True, null=True) date_of_birth = models.DateField(blank=True, null=True)
mailing_address = models.TextField(blank=True, null=True) mailing_address = models.TextField(blank=True, null=True)
country = models.CharField(blank=True, null=True, max_length=255) country = CountryField(blank=True, null=True)
telephone_number = models.CharField(blank=True, null=True, max_length=25) telephone_number = models.CharField(blank=True, null=True, max_length=25)
occupation = models.CharField(blank=True, null=True, max_length=255) occupation = models.CharField(blank=True, null=True, max_length=255)
......
...@@ -31,6 +31,8 @@ from xmodule.course_module import CourseDescriptor ...@@ -31,6 +31,8 @@ from xmodule.course_module import CourseDescriptor
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from models import Registration, UserProfile, PendingNameChange, PendingEmailChange, CourseEnrollment
from datetime import date
log = logging.getLogger("mitx.student") log = logging.getLogger("mitx.student")
...@@ -169,7 +171,7 @@ def create_account(request, post_override=None): ...@@ -169,7 +171,7 @@ def create_account(request, post_override=None):
post_vars = post_override if post_override else request.POST post_vars = post_override if post_override else request.POST
# Confirm we have a properly formed request # Confirm we have a properly formed request
for a in ['username', 'email', 'password', 'location', 'language', 'name']: for a in ['username', 'email', 'password', 'language', 'name']:
if a not in post_vars: if a not in post_vars:
js['value'] = "Error (401 {field}). E-mail us.".format(field=a) js['value'] = "Error (401 {field}). E-mail us.".format(field=a)
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
...@@ -237,7 +239,16 @@ def create_account(request, post_override=None): ...@@ -237,7 +239,16 @@ 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.language = post_vars['language'] up.language = post_vars['language']
up.location = post_vars['location'] up.country = post_vars['country']
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.save()
# TODO (vshnayder): the LMS should probably allow signups without a particular course too # TODO (vshnayder): the LMS should probably allow signups without a particular course too
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -9,6 +9,7 @@ form { ...@@ -9,6 +9,7 @@ form {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
textarea,
input[type="text"], input[type="text"],
input[type="email"], input[type="email"],
input[type="password"] { input[type="password"] {
...@@ -34,6 +35,10 @@ form { ...@@ -34,6 +35,10 @@ form {
} }
} }
textarea {
height: 60px;
}
input[type="submit"] { input[type="submit"] {
@include button(shiny, $blue); @include button(shiny, $blue);
@include border-radius(3px); @include border-radius(3px);
......
...@@ -138,6 +138,14 @@ ...@@ -138,6 +138,14 @@
position: relative; position: relative;
z-index: 2; z-index: 2;
.input-group {
@include clearfix;
border-bottom: 1px solid rgb(210,210,210);
@include box-shadow(0 1px 0 0 rgba(255,255,255, 0.6));
margin-bottom: 30px;
padding-bottom: 10px;
}
label { label {
display: none; display: none;
} }
...@@ -146,6 +154,14 @@ ...@@ -146,6 +154,14 @@
margin-right: 5px; margin-right: 5px;
} }
textarea {
background: rgb(255,255,255);
display: block;
height: 45px;
margin-bottom: 20px;
width: 100%;
}
input[type="email"], input[type="email"],
input[type="text"], input[type="text"],
input[type="password"] { input[type="password"] {
...@@ -177,6 +193,48 @@ ...@@ -177,6 +193,48 @@
} }
} }
.citizenship, .gender, .date-of-birth {
margin-bottom: 20px;
.input-wrapper {
}
label {
display: block;
}
select {
width: 100%;
}
}
.citizenship, .gender {
float: left;
width: flex-grid(6);
}
.citizenship {
margin-right: flex-gutter();
}
.date-of-birth {
float: left;
width: flex-grid(12);
select {
@include box-sizing(border-box);
display: block;
float: left;
margin-right: flex-gutter();
max-width: flex-grid(4);
width: flex-grid(4);
&:last-child {
margin: 0px;
}
}
}
.submit { .submit {
padding-top: 10px; padding-top: 10px;
......
<%namespace name='static' file='static_content.html'/> <%namespace name='static' file='static_content.html'/>
<%! from django.core.urlresolvers import reverse %> <%! from django.core.urlresolvers import reverse %>
<%! from django_countries.countries import COUNTRIES %>
<%! from student.models import UserProfile %>
<%! from datetime import date %>
<section id="signup-modal" class="modal signup-modal"> <section id="signup-modal" class="modal signup-modal">
<div class="inner-wrapper"> <div class="inner-wrapper">
...@@ -13,28 +16,84 @@ ...@@ -13,28 +16,84 @@
<div class="notice"></div> <div class="notice"></div>
<div id="enroll_error" class="modal-form-error" name="enroll_error"></div> <div id="enroll_error" class="modal-form-error" name="enroll_error"></div>
<div id="enroll_error" name="enroll_error"></div> <div id="enroll_error" name="enroll_error"></div>
<label>E-mail</label>
<input name="email" type="email" placeholder="E-mail"> <div class="input-group">
<label>Password</label> <label>E-mail</label>
<input name="password" type="password" placeholder="Password"> <input name="email" type="email" placeholder="E-mail">
<label>Public Username</label> <label>Password</label>
<input name="username" type="text" placeholder="Public Username"> <input name="password" type="password" placeholder="Password">
<label>Full Name</label> <label>Public Username</label>
<input name="name" type="text" placeholder="Full Name"> <input name="username" type="text" placeholder="Public Username">
<label>Your Location</label> <label>Full Name</label>
<input name="location" type="text" placeholder="Your Location"> <input name="name" type="text" placeholder="Full Name">
<label>Preferred Language</label> <label>Mailing address</label>
<input name="language" type="text" placeholder="Preferred Language"> <textarea name="mailing_address" placeholder="Mailing address"></textarea>
<label class="terms-of-service"> </div>
<input name="terms_of_service" type="checkbox" value="true">
I agree to the <div class="input-group">
<a href="${reverse('tos')}">Terms of Service</a> <section class="citizenship">
</label> <label>Citizenship</label>
<label class="honor-code"> <div class="input-wrapper">
<input name="honor_code" type="checkbox" value="true"> <select name="country">
I agree to the %for country_code, country_name in COUNTRIES:
<a href="${reverse('honor')}" target="blank">Honor Code</a> <option value="${country_code}">${country_name}</option>
</label> %endfor
</select>
</div>
</section>
<section class="gender">
<label>Gender</label>
<div class="input-wrapper">
<select name="gender">
%for code, gender in UserProfile.GENDER_CHOICES:
<option value="${code}">${gender}</option>
%endfor
</select>
</div>
</section>
<section class="date-of-birth">
<label>Date 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}</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>
</div>
</section>
</div>
<div class="input-group">
<label class="terms-of-service">
<input name="terms_of_service" type="checkbox" value="true">
I agree to the
<a href="#">Terms of Service</a>
</label>
<label class="honor-code">
<input name="honor_code" type="checkbox" value="true">
I agree to the
<a href="#">Honor Code</a>
, sumarized below as:
</label>
</div>
<div class="submit"> <div class="submit">
<input name="submit" type="submit" value="Create My Account"> <input name="submit" type="submit" value="Create My Account">
......
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