mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Add a 'sumbit and add a new one' button for new bills. Fix #53
This commit is contained in:
parent
46f9807806
commit
3a2958a44e
4 changed files with 12 additions and 4 deletions
|
@ -110,7 +110,8 @@ class BillForm(Form):
|
||||||
amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
|
amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
|
||||||
payed_for = SelectMultipleField(_("For whom?"),
|
payed_for = SelectMultipleField(_("For whom?"),
|
||||||
validators=[Required()], widget=select_multi_checkbox, coerce=int)
|
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):
|
def save(self, bill, project):
|
||||||
bill.payer_id=self.payer.data
|
bill.payer_id=self.payer.data
|
||||||
|
|
|
@ -84,7 +84,10 @@
|
||||||
{{ input(form.amount) }}
|
{{ input(form.amount) }}
|
||||||
{{ input(form.payed_for) }}
|
{{ input(form.payed_for) }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{ submit(form.submit, cancel=True) }}
|
<div class="actions">
|
||||||
|
{{ form.submit(class="btn primary") }}
|
||||||
|
{% if not edit %} {{ form.submit2(class="btn") }}{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
$('#bill-form').modal('hide');
|
$('#bill-form').modal('hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{% if add_bill %} $('#new-bill').click(); {% endif %}
|
||||||
|
|
||||||
// ask for confirmation before removing an user
|
// ask for confirmation before removing an user
|
||||||
$('.action').each(function(){
|
$('.action').each(function(){
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
|
|
|
@ -245,9 +245,11 @@ def list_bills():
|
||||||
if 'last_selected_payer' in session:
|
if 'last_selected_payer' in session:
|
||||||
bill_form.payer.data = session['last_selected_payer']
|
bill_form.payer.data = session['last_selected_payer']
|
||||||
bills = g.project.get_bills()
|
bills = g.project.get_bills()
|
||||||
|
|
||||||
return render_template("list_bills.html",
|
return render_template("list_bills.html",
|
||||||
bills=bills, member_form=MemberForm(g.project),
|
bills=bills, member_form=MemberForm(g.project),
|
||||||
bill_form=bill_form
|
bill_form=bill_form,
|
||||||
|
add_bill='add_bill' in request.values
|
||||||
)
|
)
|
||||||
|
|
||||||
@main.route("/<project_id>/members/add", methods=["GET", "POST"])
|
@main.route("/<project_id>/members/add", methods=["GET", "POST"])
|
||||||
|
@ -298,7 +300,7 @@ def add_bill():
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
flash(_("The bill has been added"))
|
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)
|
return render_template("add_bill.html", form=form)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue