示例#1
0
def edit_book_page(request, book_id):
    ''' info about a book '''
    book = books_manager.get_edition(book_id)
    if not book.description:
        book.description = book.parent_work.description
    data = {'book': book, 'form': forms.EditionForm(instance=book)}
    return TemplateResponse(request, 'edit_book.html', data)
示例#2
0
def shelve(request):
    ''' put a  on a user's shelf '''
    book = books_manager.get_edition(request.POST['book'])

    desired_shelf = models.Shelf.objects.filter(
        identifier=request.POST['shelf'], user=request.user).first()

    if request.POST.get('reshelve', True):
        try:
            current_shelf = models.Shelf.objects.get(user=request.user,
                                                     edition=book)
            outgoing.handle_unshelve(request.user, book, current_shelf)
        except models.Shelf.DoesNotExist:
            # this just means it isn't currently on the user's shelves
            pass
    outgoing.handle_shelve(request.user, book, desired_shelf)
    return redirect('/')