From e9b9a06779f3c49b8422c267926f2fd45f7e5df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Sureau?= Date: Fri, 29 Jul 2011 17:14:33 +0200 Subject: [PATCH] Adding bill works --- TODO | 3 ++- budget/templates/add_bill.html | 4 ++++ budget/templates/home.html | 4 ++-- budget/templates/list_bills.html | 10 +++++++++- budget/utils.py | 2 +- budget/web.py | 1 - 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index c56889e..331fa97 100644 --- a/TODO +++ b/TODO @@ -1,2 +1,3 @@ * Find a way to make the couple (name, project) unique. -* use a psql backend rather than sqlite +* Use a psql backend rather than sqlite +* If the members list of a project is empty, propose the user to define the members diff --git a/budget/templates/add_bill.html b/budget/templates/add_bill.html index 9b13b2e..8dec74c 100644 --- a/budget/templates/add_bill.html +++ b/budget/templates/add_bill.html @@ -1,5 +1,9 @@ {% extends "layout.html" %} +{% block top_menu %} +Back to the list +{% endblock %} + {% block content %}

Let's add a bill

diff --git a/budget/templates/home.html b/budget/templates/home.html index 5fcdf90..6fd955a 100644 --- a/budget/templates/home.html +++ b/budget/templates/home.html @@ -3,7 +3,7 @@ {% block content %}

Welcome on the budget manager

-
+

Log to an existing project...

{{ auth_form.hidden_tag() }} @@ -13,7 +13,7 @@

{{ auth_form.submit }}

-
+

...or create a new project

{{ project_form.hidden_tag() }} diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index 145f4f4..6d4807b 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -1,4 +1,12 @@ {% extends "layout.html" %} + +{% block top_menu %} + +{% endblock %} + {% block content %}
    @@ -7,7 +15,7 @@ {% endfor %}
{% set form=member_form %} - {% include "member_form.html" %} + {#% include "member_form.html" %#}
{% if bills.count() > 0 %} diff --git a/budget/utils.py b/budget/utils.py index f3f0458..a5f1474 100644 --- a/budget/utils.py +++ b/budget/utils.py @@ -7,7 +7,7 @@ from forms import BillForm def get_billform_for(project_id): """Return an instance of BillForm configured for a particular project.""" form = BillForm() - payers = [(m.id, m.name) for m in Project.query.get("blah").members] + payers = [(m.id, m.name) for m in Project.query.get(project_id).members] form.payed_for.choices = form.payer.choices = payers return form diff --git a/budget/web.py b/budget/web.py index 2147359..f8ede3c 100644 --- a/budget/web.py +++ b/budget/web.py @@ -100,7 +100,6 @@ def add_member(project): @app.route("//add", methods=["GET", "POST"]) @requires_auth def add_bill(project): - # FIXME: make it work. form = get_billform_for(project.id) if request.method == 'POST': if form.validate():