Wire up the donation cancel button
This commit is contained in:
parent
94b283d0e9
commit
243fc217ce
|
@ -205,3 +205,15 @@ def panel():
|
||||||
return render_template("panel.html",
|
return render_template("panel.html",
|
||||||
one_times=lambda u: [d for d in u.donations if d.type == DonationType.one_time],
|
one_times=lambda u: [d for d in u.donations if d.type == DonationType.one_time],
|
||||||
recurring=lambda u: [d for d in u.donations if d.type == DonationType.monthly and d.active])
|
recurring=lambda u: [d for d in u.donations if d.type == DonationType.monthly and d.active])
|
||||||
|
|
||||||
|
@html.route("/cancel/<id>")
|
||||||
|
@loginrequired
|
||||||
|
def cancel(id):
|
||||||
|
donation = Donation.query.filter(Donation.id == id).first()
|
||||||
|
if donation.user != current_user:
|
||||||
|
abort(401)
|
||||||
|
if donation.type != DonationType.monthly:
|
||||||
|
abort(400)
|
||||||
|
donation.active = False
|
||||||
|
db.commit()
|
||||||
|
return redirect("/panel")
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
value = 1;
|
value = 1;
|
||||||
}
|
}
|
||||||
|
if (value <= 0) {
|
||||||
|
value = 1;
|
||||||
|
}
|
||||||
e.target.value = value;
|
e.target.value = value;
|
||||||
donation.amount = value * 100;
|
donation.amount = value * 100;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue