예제 #1
0
def new_link():
    form = LinkForm()
    if form.validate_on_submit():
        link = Link(name=form.name.data, url=form.url.data)
        db.session.add(link)
        db.session.commit()
        return redirect(url_for("blog.index"))
    return render_template("/admin/new_link.html", form=form)
예제 #2
0
파일: admin.py 프로젝트: amchii/myblog
def new_link():
    form = LinkForm()
    if form.validate_on_submit():
        link = Link(name=form.name.data, url=form.url.data)
        db.session.add(link)
        db.session.commit()
        flash("Link created.", "success")
        return redirect(url_for(".manage_link"))
    return render_template("admin/new_link.html", form=form)
예제 #3
0
def edit_link(link_id):
    link = Link.query.get_or_404(link_id)
    form = LinkForm()
    if form.validate_on_submit():
        link.url = form.url.data
        link.name = form.name.data
        db.session.commit()
        return redirect_back()
    form.name.data = link.name
    form.url.data = link.url
    return render_template("admin/edit_link.html", form=form)
예제 #4
0
def new_link():
    form=LinkForm()
    if form.validate_on_submit():
        name=form.name.data
        url=form.url.data
        link=Link(name=name,url=url)
        db.session.add(link)
        db.session.commit()
        flash('Link created','success')
        return redirect(url_for('.manage_link'))
    return render_template('admin/new_link.html',form=form)
예제 #5
0
def edit_link(link_id):
    form=LinkForm()
    link=Link.query.get_or_404(link_id)
    if form.validate_on_submit():
        link.name=form.name.data
        link.url=form.url.data
        db.session.commit()
        flash('Link updated','success')
        return redirect(url_for('.manage_link'))
    form.name.data=link.name
    form.url.data=link.url
    return render_template('admin/edit_link.html',form=form)