示例#1
0
def edit_bookmark(bookmark_id):
    bookmark = Bookmark.query.get_or_404(bookmark_id)
    if current_user != bookmark.user:
        return render_template('403.html')
    form = BookmarkForm(obj=bookmark)
    if form.validate_on_submit():
        form.populate_obj(bookmark)
        db.session.commit()
        flash("Stored '{}'".format(bookmark.description))
        return redirect(url_for('user', username=current_user.username))
    return render_template('bookmark_form.html',
                           form=form,
                           title="Edit bookmark")
示例#2
0
文件: views.py 项目: schu/bookmarks
def bookmark_edit(id):
    bookmark = Bookmark.query.filter_by(id=id).first()
    if not bookmark:
        return abort(404)
    form = BookmarkForm(request.form, obj=bookmark)
    if form.validate_on_submit():
        form.populate_obj(bookmark)
        db.session.add(bookmark)
        db.session.commit()
        flash(u'Done!')
        return redirect('%d' % bookmark.id)
    flash_errors(form)
    return render_template('bookmark-form.html', form=form)
示例#3
0
文件: views.py 项目: schu/bookmarks
def bookmark_edit(id):
    bookmark = Bookmark.query.filter_by(id=id).first()
    if not bookmark:
        return abort(404)
    form = BookmarkForm(request.form, obj=bookmark)
    if form.validate_on_submit():
        form.populate_obj(bookmark)
        db.session.add(bookmark)
        db.session.commit()
        flash(u'Done!')
        return redirect('%d' % bookmark.id)
    flash_errors(form)
    return render_template('bookmark-form.html', form=form)