views.py 1.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
from django.http import HttpResponse
from django.shortcuts import render
from django.template import RequestContext, loader

from api.models import Building, Room

# Create your views here.
def index(request):
    template = loader.get_template('index.html')
    context = RequestContext(request, {
    })
    return HttpResponse(template.render(context))
13
14

def buildings(request):
Jason Yeomans's avatar
Jason Yeomans committed
15
    building_list = Building.objects.order_by('name')[:5]
16
17
    template = loader.get_template('buildings.html')
    context = RequestContext(request, {
Jason Yeomans's avatar
Jason Yeomans committed
18
        'building_list' : building_list,
19
20
    })
    return HttpResponse(template.render(context))
21
22
23
24
25
26
27
28
29
30

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))
Jason D Yeomans's avatar
Jason D Yeomans committed
31
32
33
34
35
36

def login(request):
    template = loader.get_template('login.html')
    context = RequestContext(request, {
    })
    return HttpResponse(template.render(context))