From 3a2958a44ea6bc5cf452f2e75f9eb372ee0d513d Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Mon, 28 Nov 2011 01:42:02 +0100 Subject: [PATCH] Add a 'sumbit and add a new one' button for new bills. Fix #53 --- budget/forms.py | 3 ++- budget/templates/forms.html | 5 ++++- budget/templates/list_bills.html | 2 ++ budget/web.py | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/budget/forms.py b/budget/forms.py index 0e95c73..dccf5fa 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -110,7 +110,8 @@ class BillForm(Form): amount = CommaDecimalField(_("Amount paid"), validators=[Required()]) payed_for = SelectMultipleField(_("For whom?"), validators=[Required()], widget=select_multi_checkbox, coerce=int) - submit = SubmitField(_("Send the bill")) + submit = SubmitField(_("Submit")) + submit2 = SubmitField(_("Submit and add a new one")) def save(self, bill, project): bill.payer_id=self.payer.data diff --git a/budget/templates/forms.html b/budget/templates/forms.html index 5c6a40e..10b6e0c 100644 --- a/budget/templates/forms.html +++ b/budget/templates/forms.html @@ -84,7 +84,10 @@ {{ input(form.amount) }} {{ input(form.payed_for) }} - {{ submit(form.submit, cancel=True) }} +
+ {{ form.submit(class="btn primary") }} + {% if not edit %} {{ form.submit2(class="btn") }}{% endif %} +
{% endmacro %} diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index 59692d5..b698da6 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -22,6 +22,8 @@ $('#bill-form').modal('hide'); }); + {% if add_bill %} $('#new-bill').click(); {% endif %} + // ask for confirmation before removing an user $('.action').each(function(){ $(this).hide(); diff --git a/budget/web.py b/budget/web.py index 2dc014a..5b10460 100644 --- a/budget/web.py +++ b/budget/web.py @@ -245,9 +245,11 @@ def list_bills(): if 'last_selected_payer' in session: bill_form.payer.data = session['last_selected_payer'] bills = g.project.get_bills() + return render_template("list_bills.html", bills=bills, member_form=MemberForm(g.project), - bill_form=bill_form + bill_form=bill_form, + add_bill='add_bill' in request.values ) @main.route("//members/add", methods=["GET", "POST"]) @@ -298,7 +300,7 @@ def add_bill(): db.session.commit() flash(_("The bill has been added")) - return redirect(url_for('.list_bills')) + return redirect(url_for('.list_bills', add_bill=form.submit2.data)) return render_template("add_bill.html", form=form)