Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
worblehat-old/python/web/library/views.py

20 lines
818 B
Python

from web.library.models import *
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
# Create your views here.
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})