Commit 131743f0 authored by Daniel W Bond's avatar Daniel W Bond

added fancy js field

parent 6d839006
......@@ -80,6 +80,8 @@
</div>
</div>
{% load humanize %}
<div class="col-md-8">
<div class="panel panel-default">
......@@ -88,8 +90,39 @@
</div>
<div class="panel-body">
<form action="" method="post">{% csrf_token %}
<form class="form-horizontal" action="" method="post">{% csrf_token %}
{{ my_form.as_p }}
<div class="form-group">
<label>Neighborhood</label>
<select id="neighborhood" name="neighborhood">
{% for neighborhood in neighborhoods %}
<option value="{{ neighborhood.0 }}">{{ neighborhood.1 }}</option>
{% endfor %}
</select>
<label>Building</label>
<select id="building" name="building">
<option value="">---</option>
{% for building in buildings %}
<option value="{{ building.name }}" class="{{ building.neighbourhood }}">{{ building.name }}</option>
{% endfor %}
</select>
<label>Floor</label>
<select id="floor" name="floor">
<option value="">---</option>
{% for floor in floors %}
<option value="{{ floor.slug }}" class="{{ floor.building.name }}">{{ floor.number|ordinal }}</option>
{% endfor %}
</select>
<label>Room</label>
<select id="room" name="room">
<option value="">---</option>
{% for room in rooms %}
<option value="{{ room.number }}" class="{{ room.floor.slug }}">{{ room.number }}</option>
{% endfor %}
</select>
</div>
<input type="submit" value="Save" class="btn btn-primary"/>
</form>
</div>
......@@ -99,4 +132,13 @@
</div>
{% endblock %}
{% endblock content %}
{% block javascript %}
<script type="text/javascript" src="/static/js/jquery.chained.min.js"></script>
<script>
$("#building").chained("#neighborhood");
$("#floor").chained("#building");
$("#room").chained("#floor");
</script>
{% endblock javascript %}
......@@ -14,7 +14,8 @@ from braces.views import LoginRequiredMixin, FormValidMessageMixin
from cas.views import login as cas_login
from ratelimit.decorators import ratelimit
# imports from your apps
from .models import Student, Major, Room, Confirmation
from .models import Student, Major, Confirmation
from housing.models import Building, Floor, Room
from .forms import (StudentUpdateForm, WelcomeNameForm, WelcomePrivacyForm,
WelcomeSocialForm)
......@@ -223,6 +224,11 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
form.fields['room'].widget = HiddenInput()
context['my_form'] = form
context['neighborhoods'] = Building.NEIGHBOURHOOD_CHOICES
context['buildings'] = Building.objects.all()
context['floors'] = Floor.objects.all()
context['rooms'] = Room.objects.all()
return context
def form_valid(self, 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