mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 04:31:49 +02:00
api settle branch implementation
This commit is contained in:
parent
6f3a389e00
commit
5b042fdecc
2 changed files with 24 additions and 2 deletions
|
@ -174,8 +174,8 @@
|
||||||
<label class="col-3" for="payed_for">{{ _("For whom?") }}</label>
|
<label class="col-3" for="payed_for">{{ _("For whom?") }}</label>
|
||||||
<div id="payed_for" class="controls col-9">
|
<div id="payed_for" class="controls col-9">
|
||||||
<p>
|
<p>
|
||||||
<a class="badge badge-secondary" href="#" classid="selectall" onclick="selectCheckboxes(true)">{{ _("Everyone") }}</a>
|
<a class="badge badge-secondary" href="#" classid="selectall" onclick="selectCheckboxes(true)">{{ _("Everyone!!!!!!!") }}</a>
|
||||||
<a class="badge badge-secondary" href="#" id="selectnone" onclick="selectCheckboxes(false)">{{_("No one")}}</a>
|
<a class="badge badge-secondary" href="#" id="selectnone" onclick="selectCheckboxes(false)">{{_("No one!!!")}}</a>
|
||||||
</p>
|
</p>
|
||||||
<div class="d-flex flex-column flex-wrap overflow-auto" style="max-height: 20em;">
|
<div class="d-flex flex-column flex-wrap overflow-auto" style="max-height: 20em;">
|
||||||
{% for key, value, checked in form.payed_for.iter_choices() | sort(attribute='1') %}
|
{% for key, value, checked in form.payed_for.iter_choices() | sort(attribute='1') %}
|
||||||
|
|
|
@ -747,6 +747,28 @@ def add_bill():
|
||||||
|
|
||||||
return render_template("add_bill.html", form=form)
|
return render_template("add_bill.html", form=form)
|
||||||
|
|
||||||
|
@main.route("/<project_id>/settle", methods=["GET", "POST"])
|
||||||
|
def settle_bill():
|
||||||
|
form = get_billform_for(g.project)
|
||||||
|
if request.method == "POST":
|
||||||
|
if form.validate():
|
||||||
|
# save last selected payer in session
|
||||||
|
session["last_selected_payer"] = form.payer.data
|
||||||
|
session.update()
|
||||||
|
|
||||||
|
db.session.add(form.export(g.project))
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
flash(_("The bill has been settled"))
|
||||||
|
|
||||||
|
args = {}
|
||||||
|
if form.submit2.data:
|
||||||
|
args["add_bill"] = True
|
||||||
|
|
||||||
|
return redirect(url_for(".list_bills", **args))
|
||||||
|
|
||||||
|
return render_template("add_bill.html", form=form)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/<project_id>/delete/<int:bill_id>", methods=["POST"])
|
@main.route("/<project_id>/delete/<int:bill_id>", methods=["POST"])
|
||||||
def delete_bill(bill_id):
|
def delete_bill(bill_id):
|
||||||
|
|
Loading…
Reference in a new issue