Example #1
0
def editBook(request):
    book=models.Book.objects.get(id=request.GET['bookid'])
    username=request.session['username']
    fields={'title':book.title,'price':book.price,'author':book.author,'publisher':book.publisher}
    form=NewBookForm(initial=fields)
    res=render(request,'BRMapp/edit-book.html',{'form':form,'book':book,'username':username})
    return res
Example #2
0
def edit(request):  #second
    if request.method == 'POST':
        form = NewBookForm(request.POST)
        book = models.Book()  #############3
        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('BRMapp/view-books')
Example #3
0
def add(request):
    if request.method=='POST':
        f=NewBookForm(request.POST)
        b=models.book()
        b.title=f.data['title']
        b.author=f.data['author']
        b.price=f.data['price']
        b.publisher=f.data['publisher']
        b.save()
    s="record stored <br> <a href='/BRMapp/view-book'>view all books</a>"
    return HttpResponse(s)
Example #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 = "Record stored<br><a href='view-book'>view all books>"
    return HttpResponse(s)
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 HttpResponseRedirect('/BRMapp/view-books')
Example #6
0
def edit(request):
    if request.method=='POST':
        form=NewBookForm(request.POST)
        b=models.book()
        b.id=request.POST['bookid']
        b.title=form.data['title']
        b.author=form.data['author']
        b.price=form.data['price']
        b.publisher=form.data['publisher']
        b.save()
    return HttpResponseRedirect('BRMapp/view-book')
Example #7
0
def editBook(request):
    book = models.Book.objects.get(id=request.GET['bookid'])
    fields = {
        'title': book.title,
        'price': book.price,
        'author': book.author,
        'publishr': book.publisher
    }
    form = NewBookForm(initial=fields)
    res = render(request, 'edit_book.html', {'form': form, 'book': book})
    return res
Example #8
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 = "Record Stored <br> <a href='/BRMapp/view-books'> View All Books</a>"
    return HttpResponse(s)
Example #9
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('view-books')
Example #10
0
def add(request):
    if request.method=='POST':
     #username=request.session['username']
     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)
Example #11
0
def newBook(request):
    try:
        username = request.session['username']
    except:
        return HttpResponseRedirect('login')
    else:
        form = NewBookForm()
        res = render(request, 'BRMapp/new_book.html', {
            'form': form,
            'username': username
        })
        return res
Example #12
0
def edit(request):
    try:
        username = request.session['username']
    except:
        return HttpResponseRedirect('login')
    if request.method == 'POST':
        form = NewBookForm(request.POST)
        book = models.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('view-books')
Example #13
0
def add(request):
    try:
        username = request.session['username']
    except:
        return HttpResponseRedirect('login')
    else:
        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 = "<h1 style='color:white;text-align:center;background:black'>Book details stored successfully</h1><br><center><a style='color:white;text-align:center;background:green;text-decoration:none;font-size:30px' href='view-books'>Click to view Books</a></center>"
            return HttpResponse(s)
Example #14
0
def add(request):  #making a function to add data which is filled by the user
    if request.method == 'POST':
        form = NewBookForm(
            request.POST
        )  #To obtain form data which is stored in the form variable after submit
        book = models.Book(
        )  #making a object of the class Book by making a variable named book to represent record
        book.title = form.data[
            'title']  #filling the record and inserting into table
        book.price = form.data[
            'price']  #filling the record and inserting into table
        book.author = form.data[
            'author']  #filling the record and inserting into table
        book.publisher = form.data[
            'publisher']  #filling the record and inserting into table
        book.save()
        s = "Record Stored<br><a href='/BRMapp/view-books'>view all Book</a>"
        return HttpResponse(s)
Example #15
0
def editBook(request):
    try:
        username = request.session['username']
    except:
        return HttpResponseRedirect('login')
    else:
        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.html', {
            "form": form,
            "book": book,
            'username': username
        })
        return res
Example #16
0
def newbook(request):
    f=NewBookForm()
    return render(request,'BRMapp/new_book.html',{'f':f})
Example #17
0
def newBook(request):
    form=NewBookForm()
    username=request.session['username']
    res=render(request,'BRMapp/new-book.html',{'form':form,'username':username})
    return res
Example #18
0
def newBook(request):
    form = NewBookForm()
    res = render(request, 'BRMapp/newbook.html', {'form': form})
    return res
Example #19
0
def newBook(request):  #making a function to see form
    form = NewBookForm(
    )  #making a object of the form class NewBookForm by making a variable named form
    res = render(request, 'BRMapp/new_book.html', {'form': form})
    return res