Пример #1
0
def edit(entry_id):
    entry = firestore.read(entry_id)
    if request.method == 'POST':
        data = request.form.to_dict(flat=True)
        entry = firestore.update(data, entry_id)
        return redirect(url_for('.view', entry_id=entry['id']))
    return render_template('form.html', action='Edit', entry=entry)
Пример #2
0
def update(book_id):
    book = firestore.read(book_id)
    form = BookForm(data=book)

    # Process form if submission request
    if form.validate_on_submit():
        data = form.data
        book = firestore.update(data, book_id)
        return redirect(url_for('app.view', book_id=book['id']))

    book = firestore.read(book_id)
    return render_template('book_form.html', form=form, header="Update Book")
Пример #3
0
def edit(book_id):
    book = firestore.read(book_id)

    if request.method == 'POST':
        data = request.form.to_dict(flat=True)

        # If an image was uploaded, update the data to point to the new image.
        image_url = upload_image_file(request.files.get('image'))

        if image_url:
            data['imageUrl'] = image_url

        book = firestore.update(data, book_id)

        return redirect(url_for('.view', book_id=book['id']))

    return render_template('form.html', action='Edit', book=book)