Exemplo n.º 1
0
def edit(request):
    if request.method == 'POST':
        form = NewBookForm(request.POST)
        book = Book()
        book.id = request.POST['bookid']
        book.title = form.data['title']
        book.price = form.data['price']
        book.author = form.data['author']
        book.publisher = form.data['publisher']
        book.save()
    return HttpResponseRedirect('BRM/view_book.html')
Exemplo n.º 2
0
def add(request):
    if request.method == 'POST':
        form = NewBookForm(request.POST)
        book = Book()
        book.title = form.data['title']
        book.price = form.data['price']
        book.author = form.data['author']
        book.publisher = form.data['publisher']
        book.save()
    s = "Recored stored successfully<br><a href='BRM/view_book'>View All Book</a>"
    return HttpResponse(s)
Exemplo n.º 3
0
def editBook(request):
    book = 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, 'BRM/edit_book.html', {'form': form, 'book': book})
    return res
Exemplo n.º 4
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 = "Redord Stored<br><a href='/BRM/view-books'>View all Books</a>"
    return HttpResponse(s)
Exemplo n.º 5
0
def newBook(request):
    form = NewBookForm()
    res = render(request, 'BRM/new_book.html', {'form': form})
    return res