Wire up the donation cancel button

This commit is contained in:
Drew DeVault 2015-09-06 16:37:25 -04:00
parent 94b283d0e9
commit 243fc217ce
2 changed files with 15 additions and 0 deletions

View File

@ -205,3 +205,15 @@ def panel():
return render_template("panel.html",
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])
@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")

View File

@ -43,6 +43,9 @@
if (isNaN(value)) {
value = 1;
}
if (value <= 0) {
value = 1;
}
e.target.value = value;
donation.amount = value * 100;
});