diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2011-07-31 00:53:12 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2011-07-31 00:53:12 +0200 |
| commit | 3417a5a7d48ade7744586a711127d2302f58109a (patch) | |
| tree | c9ab5bfc50596f582bd51fd414ff73bab1c66c4c | |
| parent | 2df6e11f05eff9bd855079097aa865f52689d7ca (diff) | |
| download | ihatemoney-mirror-3417a5a7d48ade7744586a711127d2302f58109a.zip ihatemoney-mirror-3417a5a7d48ade7744586a711127d2302f58109a.tar.gz ihatemoney-mirror-3417a5a7d48ade7744586a711127d2302f58109a.tar.bz2 | |
List the projects in session into the home page.
This allows easier access when people don't remembre the name / url of their projects.
| -rw-r--r-- | budget/templates/home.html | 14 | ||||
| -rw-r--r-- | 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 @@ <p>{{ auth_form.password.label }}<br /> {{ auth_form.password }}</p> <p>{{ auth_form.submit }}</p> </form> - <h3>Recently visisted projects</h3> - <ul> - {% for project in session['projects'] %} - <li>{{ project }}</li> - {% endfor %} - </ul> + {% if 'projects' in session %} + <h3>Recently visisted projects</h3> + <ul> + {% for id, name in session['projects'] %} + <li><a href="{{ url_for("list_bills", project_id=id) }}">{{ name }}</a></li> + {% endfor %} + </ul> + {% endif %} </div> <form class="span-10 last" action="{{ url_for('create_project') }}" method="post" class="container span-24 add-bill"> 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) |
