Exemple #1
0
def insertBook(request):
    if request.POST:
        post = request.POST
        __Author = Author.objects.filter(Name = post["AuthorName"])
        if __Author:
            for author in __Author:
                new_book = Book(
                ISBN = post["ISBN"],
                Title = post["Title"],
                AuthorID = author,
                Publisher = post["Publisher"],
                PublishDate = post["PublishDate"],
                Price = post["Price"])            
                new_book.save()            
            return render_to_response("insertBook.html")
        else:
            return render_to_response("insertAuthor.html",{
                "ISBN":post["ISBN"],
                "Title":post["Title"],
                "AuthorName":post["AuthorName"],
                "Publisher":post["Publisher"],
                "PublishDate":post["PublishDate"],
                "Price":post["Price"],
            })
    return render_to_response("insertBook.html")
Exemple #2
0
def bookedit(req):
	isbn=req.GET.get( 'isbn')
	title=req.GET.get( 'title')
	authorid=req.GET.get( 'authorid')
	publisher=req.GET.get( 'publisher')
	publishdate=req.GET.get('publishdate')
	price=req.GET.get('price')
	i=Book(ISBN=isbn,Title=title,AuthorID=authorid,Publisher=publisher,PublishDate=publishdate,Price=price)
	i.save()
	for i in Author.objects.all():
		if(i.AuthorID==authorid):
			page=Book.objects.all()
			book_list=play(page)
			return render(req,'sucess.html',{})
	return render(req,'addauthor.html',{'authorid':authorid})
Exemple #3
0
def AddBookSuccess(request):
    book = Book()
    if request.POST:
        try:
            book.ISBN = request.POST["ISBN"]
            book.Title = request.POST['Title']
            book.AuthorID = request.POST['AuthorID']
            book.Publisher = request.POST['Publisher']
            book.PublicationDate = request.POST['PublicationDate']
            book.price = request.POST['price']
            book.save()
            return render_to_response('AddBookSuccess.html',{'book':book})
        except Author.DoesNotExist:
            return render_to_response('AuthorNotExist.html')
    else:
        return render_to_response('AddBook.html')
Exemple #4
0
def insertAuthor(request):
    if request.POST:
        post = request.POST
        new_author = Author(
            AuthorID = post["AuthorID"],
            Name =  post.get('_AuthorName',False),
            Age = post["Age"],
            Country = post["Country"]
        )
        new_author.save()
        new_book = Book(
            ISBN = post.get('ISBN',False),
            Title = post.get('Title',False),
            AuthorID = new_author,
            Publisher = post.get('Publisher',False),
            PublishDate = post.get('PublishDate',False),
            Price = post.get('Price',False)
        )
        new_book.save()
        return HttpResponseRedirect("/book/")
    return render_to_response("insertAuthor.html")