2011-03-05 20:33:11 +01:00
|
|
|
from web.library.models import *
|
2011-03-06 12:31:51 +01:00
|
|
|
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
2011-03-05 20:33:11 +01:00
|
|
|
from django.shortcuts import render_to_response, get_object_or_404
|
|
|
|
|
|
|
|
|
2011-03-06 12:31:51 +01:00
|
|
|
|
|
|
|
|
2010-09-17 17:14:10 +02:00
|
|
|
# Create your views here.
|
2011-03-05 20:33:11 +01:00
|
|
|
def BookView(request,book_identifier):
|
|
|
|
book=get_object_or_404(Book,isbn=book_identifier)
|
|
|
|
people = book.persons.all()
|
|
|
|
return render_to_response('book/view.html', {'book' : book, 'people' : people})
|
|
|
|
|
|
|
|
def BookRedirect(request,book_identifier):
|
|
|
|
ident=get_object_or_404(Id,id=book_identifier)
|
|
|
|
return HttpResponseRedirect('/book/'+ident.book.isbn)
|
|
|
|
|
|
|
|
def PersonView(request,person_identifier):
|
|
|
|
person = get_object_or_404(Person,id=person_identifier)
|
|
|
|
books = person.books.all()
|
|
|
|
return render_to_response('person/view.html', {'title' : 'Worblehat: person '+person.first_name+' '+person.last_name,'person' : person, 'books' : books})
|
2011-03-06 12:31:51 +01:00
|
|
|
|
|
|
|
def MapView(request,shelf_identifier):
|
|
|
|
if shelf_identifier not in Placement.get_all_shelves():
|
|
|
|
raise Http404()
|
|
|
|
shelf_list = Placement.shelf_as_list_row_then_col(shelf_identifier)
|
|
|
|
return render_to_response('map/view.html', {'shelf': shelf_list})
|