Ejemplo n.º 1
0
def save_form():
    ID = request.form["id"]
    if not ID:
        raise Exception("no id")

    if not allowed_knowl_id.match(ID):
        flask.flash(
            """Oops, knowl id '%s' is not allowed.
                  It must consist of lower/uppercase characters,
                  no spaces, numbers or '.', '_' and '-'."""
            % ID,
            "error",
        )
        return flask.redirect(url_for(".index"))

    k = Knowl(ID)
    k.title = request.form["title"]
    k.content = request.form["content"]
    k.quality = request.form["quality"]
    k.timestamp = datetime.now()
    k.save(who=current_user.get_id())
    from knowl import save_history

    save_history(k, current_user.get_id())
    return flask.redirect(url_for(".show", ID=ID))
Ejemplo n.º 2
0
def save_form():
    ID = request.form['id']
    if not ID:
        raise Exception("no id")

    if not allowed_knowl_id.match(ID):
        flask.flash("""Oops, knowl id '%s' is not allowed.
                  It must consist of lower/uppercase characters,
                  no spaces, numbers or '.', '_' and '-'.""" % ID, "error")
        return flask.redirect(url_for(".index"))

    k = Knowl(ID)
    k.title = request.form['title']
    k.content = request.form['content']
    k.quality = request.form['quality']
    k.timestamp = datetime.now()
    k.save(who=current_user.get_id())
    from knowl import save_history
    save_history(k, current_user.get_id())
    return flask.redirect(url_for(".show", ID=ID))