Commit 4468c0e3 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

modified form fields, instantiation, and chosen.js options to render major for update_student

parent 6403bbb2
......@@ -80,7 +80,7 @@ class StudentUpdateForm(forms.Form):
room = SelectRoomField(queryset=Room.objects.all(), required=False)
privacy = forms.TypedChoiceField(choices=Student.PRIVACY_CHOICES)
major = forms.ModelChoiceField(queryset=Major.objects.all(), required=False)
major = forms.ModelMultipleChoiceField(queryset=Major.objects.all(), required=False)
graduating_year = forms.IntegerField()
def clean(self):
......
......@@ -212,7 +212,7 @@
</div>
<div class="form-group">
<label for="{{ my_form.major.id_for_label }}" class="col-md-2">
Major<br />(select one)
Major(s)
</label>
<div class="col-md-4">
{{ my_form.major }}
......@@ -268,7 +268,7 @@
<script type="text/javascript" src="/static/js/chained.min.js"></script>
<script type="text/javascript" src="/static/js/chosen.min.js"></script>
<script>
$(".chosen-select").chosen()
$(".chosen-select").chosen({max_selected_options: 2});
</script>
{% include 'room_selection_script.html' %}
{% endblock javascript %}
......@@ -154,6 +154,7 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
context = super(UpdateStudent, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
majors = [pk_or_none(me, major) for major in me.major.all()]
form = StudentUpdateForm(initial={'first_name': me.user.first_name,
'last_name': me.user.last_name,
......@@ -161,7 +162,7 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
'show_gender': me.show_gender,
'room': pk_or_none(me, me.room),
'privacy': me.privacy,
'major': pk_or_none(me, me.major),
'major': majors,
'graduating_year': me.graduating_year,
'on_campus': me.on_campus, })
......
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