def getHistory():
    username = "" #request.args.get("username","")
    if "user" in session:
        username = session["user"]
    res = []
    if username:
        res = db.getHistory(username)
    return json.dumps(res)
def history():
    if "user" not in session:
        return redirect(url_for("login"))
    if request.method == "GET":
        username = session["user"]
        history = []
        if username:
            history = db.getHistory(username)
        return render_template("history.html",history=history)
    else:
        button = request.form["button"]
        username = ""
        if "user" in session:
            username = session["user"]
        res = 0
        if (button == "Clear History") and username:
            res = db.clearHistory(username)
        error = ""
        if res == 0:
            error = "user does not exist"
        history = db.getHistory(username)
        return render_template("history.html",history=history,error=error)
Ejemplo n.º 3
0
def historyPage(pagename):
    if not config.sanePagename(pagename):
        abort(404)

    history = json.dumps(db.getHistory(pagename))

    form = EmptyForm()
    return render_template("history-wikipage.html",
                           styled_domain_name=STYLED_DOMAIN_NAME,
                           license=config.LICENSE,
                           pagename=pagename,
                           wikipage=True,
                           form=form,
                           history=history)