From 3417a5a7d48ade7744586a711127d2302f58109a Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Sun, 31 Jul 2011 00:53:12 +0200 Subject: [PATCH] List the projects in session into the home page. This allows easier access when people don't remembre the name / url of their projects. --- budget/templates/home.html | 14 ++++++++------ budget/web.py | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/budget/templates/home.html b/budget/templates/home.html index 7a0cafc..ae36d4a 100644 --- a/budget/templates/home.html +++ b/budget/templates/home.html @@ -12,12 +12,14 @@

{{ auth_form.password.label }}
{{ auth_form.password }}

{{ auth_form.submit }}

-

Recently visisted projects

- + {% if 'projects' in session %} +

Recently visisted projects

+ + {% endif %}
diff --git a/budget/web.py b/budget/web.py index f313266..1afb8c1 100644 --- a/budget/web.py +++ b/budget/web.py @@ -15,7 +15,8 @@ mail = Mail() def home(): project_form = ProjectForm() auth_form = AuthenticationForm() - return render_template("home.html", project_form=project_form, auth_form=auth_form) + return render_template("home.html", project_form=project_form, + auth_form=auth_form, session=session) @app.route("/authenticate", methods=["GET", "POST"]) def authenticate(redirect_url=None): @@ -40,7 +41,10 @@ def authenticate(redirect_url=None): form.errors['password'] = ["The password is not the right one"] else: # maintain a list of visited projects - session["projects"].append(project_id) + if "projects" not in session: + session["projects"] = [] + # add the project on the top of the list + session["projects"].insert(0, (project_id, project.name)) session[project_id] = form.password.data session.update() return redirect(redirect_url)