Commit b36e08a4 authored by Jason D Yeomans's avatar Jason D Yeomans
Browse files

Linked buildings in building list to building page (shows rooms and occupants)

parent 6338c43b
......@@ -6,4 +6,5 @@ admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^buildings/$', views.buildings, name='buildings'),
url(r'^building/(?P<buildingName>[a-zA-Z]+)$', views.building, name='building'),
)
......@@ -18,3 +18,13 @@ def buildings(request):
'building_list' : building_list,
})
return HttpResponse(template.render(context))
def building(request, buildingName):
building = Building.objects.get(name__iexact=''+buildingName)
room_list = Room.objects.filter(building__name=''+building.name).order_by('number')
template = loader.get_template('building.html')
context = RequestContext(request, {
'building' : building,
'room_list' : room_list,
})
return HttpResponse(template.render(context))
{% extends 'layouts/base.html' %} {% block title %} GMU RoomList &bull; Homepage {% endblock %} {% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>GMU</strong>ROOMLIST</h1>
<p class="lead">{{ building.name }}</p>
</div>
</div>
</div>
<ul style="list-style-type: none">
{% for room in room_list %}
<li>
{{ room.number }}
</li>
<li>
<ul>
<li>
{{ room.bedA }}
</li>
{% if room.bedB %}
<li>
{{ room.bedB }}
</li>
{% endif %}
{% if room.bedC %}
<li>
{{ room.bedC }}
</li>
{% endif %}
{% if room.bedD %}
<li>
{{ room.bedD }}
</li>
{% endif %}
</ul>
</li>
{% endfor %}
</ul>
{% endblock %}
......@@ -16,7 +16,7 @@ GMU RoomList &bull; Homepage
<ul>
{% for building in building_list %}
<li>
{{ building.name }} - {{ building.address }} {{ building.address.zip_code }}, {{ building.address.state}}
<a href="/building/{{ building.name }}">{{ building.name }}</a> - {{ building.address }} {{ building.address.zip_code }}, {{ building.address.state}}
</li>
{% endfor %}
</ul>
......
......@@ -7,12 +7,12 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Project name</a>
<a class="navbar-brand" href="/"><strong>GMU</strong>ROOMLIST</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li class="active"><a href="/">Home</a></li>
<li><a href="/#about">About</a></li>
<li><a href="/buildings">Buildings</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
......
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