Wire up the donation cancel button

static-cp-fix
Drew DeVault 10 years ago
parent 94b283d0e9
commit 243fc217ce
  1. 12
      fosspay/blueprints/html.py
  2. 3
      scripts/index.js

@ -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")

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

Loading…
Cancel
Save