Commit 34df1bd9 authored by Ben Waters's avatar Ben Waters
Browse files

using floppy forms

parent 1ebd44fb
from django import forms import floppyforms as forms
from django.db import models from django.db import models
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from mainapp.models import Student, Major, Minor, GenEd from mainapp.models import Student, Major, Minor, GenEd
# form on new page # form on new page
class StartTrajectoryForm(forms.Form): class StartTrajectoryForm(forms.Form):
majors = forms.ChoiceField(choices=[(obj.id, obj.name) for obj in majors = forms.ChoiceField(widget=forms.SelectMultiple,choices=[(obj.id, obj.name) for obj in
Major.objects.all()]) Major.objects.all()])
minors = forms.ChoiceField(choices=[(obj.id, obj.name) for obj in minors = forms.ChoiceField(widget=forms.SelectMultiple,choices=[(obj.id, obj.name) for obj in
Minor.objects.all()]) Minor.objects.all()])
class StudentForm(forms.ModelForm): class StudentForm(forms.ModelForm):
......
...@@ -19,48 +19,7 @@ New | MySchool Advisor ...@@ -19,48 +19,7 @@ New | MySchool Advisor
<div class="col-md-offset-1 col-md-10 well"> <div class="col-md-offset-1 col-md-10 well">
<form class="form-horizontal" action="{% url 'build-me' %}" method="post" role="form" enctype="multipart/form-data"> <form class="form-horizontal" action="{% url 'build-me' %}" method="post" role="form" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<fieldset> {{ starttrajectoryform.as_p }}
<legend>Select your program(s).</legend>
<div class="form-group{% if starttrajectoryform.name.errors %} has-error {% endif %}">
<label for "{{ starttrajectoryform.name.id_for_label}}" class="col-sm-2">
{{ starttrajectoryform.name.id_for_label }}</label>
<div class="col-sm-8">
{{ starttrajectoryform.name }}
{% for error in starttrajectoryform.name.errors %}
<span class="help-block">{{ error }}</span>
{% endfor %}
<!-- autocompletion would be awesome -->
</div>
<select multiple class="form-control">
{% for major in starttrajectoryform.majors.field.choices %}
<option value="{{major.id}}">{{major}}</option>
{% endfor %}
</select>
</div>
<!-- Javascript for adding an additional field -->
<!-- Ensure no more than two majors -->
<legend>Select your minor(s).</legend>
<div class="form-group{% if starttrajectoryform.name.errors %} has-error {% endif %}">
<label for "{{ starttrajectoryform.name.id_for_label }}" class="col-sm-2">
{{ starttrajectoryform.name.id_for_label }}</label>
<div class="col-sm-8">
{{ starttrajectoryform.name }}
{% for error in starttrajectoryform.name.errors %}
<span class="help-block">{{ error }}</span>
{% endfor %}
<!-- autocompletion would be awesome -->
</div>
<select multiple class="form-control">
{% for minor in starttrajectoryform.minors.fieldchoices %}
<option value="{{minor.id}}">{{minor}}</option>
{% endfor %}
</select>
</div>
<!-- Javascript for adding an additional field --> <!-- Javascript for adding an additional field -->
<!-- ensure no more than three minors --> <!-- ensure no more than three minors -->
...@@ -71,7 +30,6 @@ New | MySchool Advisor ...@@ -71,7 +30,6 @@ New | MySchool Advisor
</div> </div>
</div> </div>
</fieldset>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -20,6 +20,9 @@ from mainapp.forms import StartTrajectoryForm, StudentForm ...@@ -20,6 +20,9 @@ from mainapp.forms import StartTrajectoryForm, StudentForm
@login_required @login_required
def build_trajectory(request): def build_trajectory(request):
#process #process
if request.method == "POST":
form = StartTrajectoryForm(request.POST)
#majors = form.fie
return render_to_response('build.html', { return render_to_response('build.html', {
}) })
class StartTrajectoryView(FormView): class StartTrajectoryView(FormView):
......
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