Commit d76441eb authored by Daniel W Bond's avatar Daniel W Bond
Browse files

theoretical room selector fix-- cache list of room <option>'s for an hour, and...

theoretical room selector fix-- cache list of room <option>'s for an hour, and then js-select the room the student is staying in on load
parent a9375e40
......@@ -34,11 +34,10 @@
&nbsp;&nbsp;<label>Room</label>&nbsp;
<select id="room" name="room" class="roompicker">
<option value="">---</option>
{% load cache %}
{% cache 3600 room_list %}
{% for room in rooms %}
{% if user.student.room.pk == room.pk %}
<option value="{{ room.pk }}" class="{{ room.floor.pk }}" selected="selected">{{ room.number }}</option>
{% else %}
<option value="{{ room.pk }}" class="{{ room.floor.pk }}">{{ room.number }}</option>
{% endif %}
{% endfor %}
{% endcache %}
</select>
......@@ -280,6 +280,12 @@
$($radio.filter('[value=True]').click(function(){
$("#lives-on-campus").slideDown();
}));
// find the room a student is staying in and select it for them on page load
// this allows us to cache the list of rooms
var selectedRoom = "{{ request.user.student.room.pk }}";
$("#room").val(selectedRoom)
.find("option[value=" + selectedRoom + "]").attr('selected', true);
});
$("#lives-on-campus").hide();
......
......@@ -139,6 +139,11 @@
$($radio.filter('[value=True]').click(function(){
$("#lives-on-campus").slideDown();
}));
// find the room a student is staying in and select if for them on page load
// this allows us to cache the list of rooms
var selectedRoom = "{{ request.user.student.room.pk }}";
$("#room").val(selectedRoom)
.find("option[value=" + selectedRoom + "]").attr('selected', true);
});
$("#lives-on-campus").hide();
......
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