Exemplo n.º 1
0
def add(request):
    if request.method=='POST':
        form=NewBookForm(request.POST)
        book=models.Book()
        book.title=form.data['title']
        book.price=form.data['price']
        book.author=form.data['author']
        book.publisher=form.data['publisher']
        book.save()
    return HttpResponseRedirect('BRMApp/view-books')
Exemplo n.º 2
0
def add(request):
    if request.method == 'POST':
        form = NewBookForm(request.POST)
        book = models.Book()
        book.title = form.data['title']
        book.price = form.data['price']
        book.author = form.data['author']
        book.publisher = form.data['publisher']
        book.save()
    s = "Record stored <br> <a href='/BRMApp/view-books'>View all books</a>"
    return HttpResponse(s)
Exemplo n.º 3
0
def editBook(request):
    book = models.Book.objects.get(id=request.GET['bookid'])
    fields = {
        'title': book.title,
        'price': book.price,
        'author': book.author,
        'publisher': book.publisher
    }
    form = NewBookForm(initial=fields)
    res = render(request, 'BRMApp/edit_book.htm', {'form': form, 'book': book})
    return res
Exemplo n.º 4
0
def newBooks(request):
    form=NewBookForm()
    username=request.session['username']
    res=render(request,'BRMApp_Template/new_book.html',{'form':form})
    return res
Exemplo n.º 5
0
def newBook(request):
    form = NewBookForm()
    res = render(request, 'BRMApp/new_book.htm', {'form': form})
    return res