Ejemplo n.º 1
0
def create_gist():
    form = GistForm()

    if form.validate_on_submit():
        gist = Gist(author=g.user)
        gist.init_optional()
        form.populate_obj(gist)
        gist.maybe_save()

        flash(_("Post gist success"), "success")

        return redirect(url_for("detail_gist", gist_id=gist.pk))

    return render_template("gist/create_gist.html", form=form)
Ejemplo n.º 2
0
def create_gist():
    form = GistForm()

    if form.validate_on_submit():
        gist = Gist(author=g.user)
        gist.init_optional()
        form.populate_obj(gist)
        gist.maybe_save()

        flash(_("Post gist success"), "success")

        return redirect(url_for("detail_gist", gist_id=gist.pk))

    return render_template("gist/create_gist.html",
            form=form)
Ejemplo n.º 3
0
def edit_gist(gist_id):
    gist = Gist.query.get_or_404(gist_id)
    gist.permissions.edit.test(403)
    
    form = GistForm(
            desc=gist.desc,
            code_type=gist.code_type,
            content=gist.content,
            tags=' '.join(gist.tags),
            )

    if form.validate_on_submit():
        
        form.populate_obj(gist)
        gist.maybe_save()
        
        flash(_("Gist has been changed"), "success")
        
        return redirect(url_for("detail_gist", gist_id=gist.pk))

    return render_template("gist/create_gist.html", form=form)
Ejemplo n.º 4
0
def edit_gist(gist_id):
    gist = Gist.query.get_or_404(gist_id)
    gist.permissions.edit.test(403)

    form = GistForm(
        desc=gist.desc,
        code_type=gist.code_type,
        content=gist.content,
        tags=' '.join(gist.tags),
    )

    if form.validate_on_submit():

        form.populate_obj(gist)
        gist.maybe_save()

        flash(_("Gist has been changed"), "success")

        return redirect(url_for("detail_gist", gist_id=gist.pk))

    return render_template("gist/create_gist.html", form=form)