Commit f488cf45 authored by Daniel W Bond's avatar Daniel W Bond

support for showing gender on profile page

parent d6dc6ee5
......@@ -63,6 +63,8 @@ class StudentUpdateForm(forms.Form):
gender = MultiSelectFormField(choices=Student.GENDER_CHOICES,
label='Gender Identity (please choose all that apply)',
required=False)
show_gender = forms.BooleanField(label='Show your gender on your profile?',
required=False)
room = SelectRoomField(queryset=Room.objects.all(), label='', required=False)
......@@ -82,10 +84,13 @@ class StudentUpdateForm(forms.Form):
class WelcomeNameForm(forms.Form):
first_name = forms.CharField(label='First Name')
last_name = forms.CharField(label='Last Name')
first_name = forms.CharField(label='First Name', required=False)
last_name = forms.CharField(label='Last Name', required=False)
gender = MultiSelectFormField(choices=Student.GENDER_CHOICES,
label='Gender Identity (please choose all that apply)')
label='Gender Identity (please choose all that apply)',
required=False)
show_gender = forms.BooleanField(label='Show your gender on your profile?',
required=False)
class WelcomePrivacyForm(forms.ModelForm):
......
......@@ -122,6 +122,7 @@ class Student(TimeStampedModel):
# selectmultiple in forms
gender = MultiSelectField(max_length=25, choices=GENDER_CHOICES, blank=True)
show_gender = models.BooleanField(default=False)
privacy = models.CharField(max_length=100, choices=PRIVACY_CHOICES, default=FLOOR)
......
......@@ -69,6 +69,23 @@
<tr>
<td><h4><strong>Email</strong>: {{ student.user.email }}</h4></td>
</tr>
{% if student.show_gender %}
<tr>
<td><h4><strong>Gender</strong>:
{% for gender in student.gender %}
{% if gender == 'female' %}
<i class="fa fa-venus"></i>
{% elif gender == 'male' %}
<i class="fa fa-mars"></i>
{% elif gender == 'trans' %}
<i class="fa fa-transgender"></i>
{% elif gender == 'other' %}
<i class="fa fa-transgender-alt"></i>
{% endif %}
{% endfor %}
</h4></td>
</tr>
{% endif %}
</tbody>
</table>
</div>
......
......@@ -215,6 +215,7 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
form = StudentUpdateForm(initial={'first_name': me.user.first_name,
'last_name': me.user.last_name,
'gender': me.gender,
'show_gender': me.show_gender,
'room': pk_or_none(me, me.room),
'privacy': me.privacy,
'major': pk_or_none(me, me.major),
......@@ -264,6 +265,7 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
me.user.first_name = form.data['first_name']
me.user.last_name = form.data['last_name']
me.gender = form.data.getlist('gender')
me.show_gender = form.data.get('show_gender', False)
me.privacy = form.data['privacy']
me.graduating_year = form.data['graduating_year']
......@@ -300,7 +302,8 @@ class WelcomeName(LoginRequiredMixin, FormView):
form = WelcomeNameForm(initial={'first_name': me.user.first_name,
'last_name': me.user.last_name,
'gender': me.gender, })
'gender': me.gender,
'show_gender': me.show_gender, })
context['my_form'] = form
return context
......@@ -316,6 +319,7 @@ class WelcomeName(LoginRequiredMixin, FormView):
me.user.last_name = form.data['last_name']
me.gender = form.data.getlist('gender')
me.show_gender = form.data.get('show_gender', False)
me.completedName = True
......
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