Commit 1b8360cc authored by Daniel W Bond's avatar Daniel W Bond
Browse files

finished gender welcome page

parent d7d2e796
......@@ -4,6 +4,7 @@ from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout
from crispy_forms.bootstrap import PrependedText, AppendedText
from multiselectfield import MultiSelectFormField
# imports from your apps
from .models import Student
......@@ -47,3 +48,11 @@ class UserSettingsForm(forms.ModelForm):
class Meta:
model = Student
class WelcomeNameForm(forms.Form):
first_name = forms.CharField(label='First Name')
last_name = forms.CharField(label='Last Name')
gender = MultiSelectFormField(choices=Student.GENDER_CHOICES, label='Gender Identity (please choose all that apply)')
......@@ -27,12 +27,12 @@
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title text-center">Name & Gender</h1>
<h1 class="panel-title text-center"><strong>Name & Gender</strong></h1>
<div class="panel-body">
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
{{ my_form.as_p }}
<input type="submit" value="Save" class="btn btn-primary"/>
......@@ -118,11 +118,32 @@ class WelcomeName(LoginRequiredMixin, FormView):
form_class = WelcomeNameForm
login_url = 'login'
def get_context_data(self, **kwargs):
context = super(WelcomeName, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
form = WelcomeNameForm(initial={'first_name': me.user.first_name,
'last_name': me.user.last_name,
'gender': me.gender, })
context['my_form'] = form
return context
def form_valid(self, form):
self.obj = self.get_object()
me = Student.objects.get(user=self.request.user)
self.obj.completedName = True
me.user.first_name =['first_name']
me.user.last_name =['last_name']
#for identity in['gender']
me.gender ='gender')
me.completedName = True
return super(WelcomeName, self).form_valid(form)
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