Commit 67221b07 by Matthew Mongeau

Added countries and other demographics to be stored in db.

parent 7e25f39f
...@@ -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
...@@ -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)
......
...@@ -169,7 +169,7 @@ def create_account(request, post_override=None): ...@@ -169,7 +169,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))
...@@ -235,9 +235,11 @@ def create_account(request, post_override=None): ...@@ -235,9 +235,11 @@ def create_account(request, post_override=None):
r.register(u) r.register(u)
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']
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
......
<%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 import countries %>
<%! from student.models import UserProfile %>
<section id="signup-modal" class="modal signup-modal"> <section id="signup-modal" class="modal signup-modal">
<div class="inner-wrapper"> <div class="inner-wrapper">
...@@ -21,12 +23,24 @@ ...@@ -21,12 +23,24 @@
<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> <p>
<textarea name="mailing_address" placeholder="Mailing address"></textarea> <label>Mailing address</label>
<label>Country</label> <textarea name="mailing_address" placeholder="Mailing address"></textarea>
<input name="country" type="text" placeholder="Country of citizenship"> </p>
<label>Country of citizenship</label>
<select name="country">
%for code, country in countries.COUNTRIES:
<option value="${code}">${country}</option>
%endfor
</select>
<label>Preferred Language</label> <label>Preferred Language</label>
<input name="language" type="text" placeholder="Preferred Language"> <input name="language" type="text" placeholder="Preferred Language">
<label>Gender</label>
<select name="gender">
%for code, gender in UserProfile.GENDER_CHOICES:
<option value="${code}">${gender}</option>
%endfor
</select>
<label class="terms-of-service"> <label class="terms-of-service">
<input name="terms_of_service" type="checkbox" value="true"> <input name="terms_of_service" type="checkbox" value="true">
I agree to the I agree to the
......
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