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)
def edit_book(request, book_id): ''' edit a book cool ''' if not request.method == 'POST': return redirect('/book/%s' % request.user.localname) try: book = models.Edition.objects.get(id=book_id) except models.Edition.DoesNotExist: return HttpResponseNotFound() form = forms.EditionForm(request.POST, request.FILES, instance=book) if not form.is_valid(): return redirect(request.headers.get('Referer', '/')) form.save() outgoing.handle_update_book(request.user, book) return redirect('/book/%s' % book.fedireads_key)