def payments_post(): amount = request.form["amount"].strip() email = request.form["email"].strip() method = request.form["method"].strip() type = request.form["type"].strip() notes = request.form["notes"].strip() reference = request.form["reference"].strip() errors = payments.validate(amount, email, method, type, notes, reference) if len(errors) > 0: # this means that an error has occured for e in errors: flash(e, 'danger') return render_template('payments.html', amount=amount, email=email, method=method, type=type, notes=notes, reference=reference), 400 # Cajole the post data into integers amount = float(amount) type = int(type) method = int(method) payments.create(amount, email, method, type, notes, reference) flash("Thank you!", "success") return payments_get()
def payments_post(): amount = get_post_value("amount") email = get_post_value("email") method = get_post_value("method") type = get_post_value("type") notes = get_post_value("notes") reference = get_post_value("reference") errors = payments.validate(amount, email, method, type, notes, reference) if len(errors) > 0: # this means that an error has occured for e in errors: flash(e, 'danger') return render_template('payments.html', amount=amount, email=email, method=method, type=type, notes=notes, reference=reference), 400 # Cajole the post data into integers amount = int(amount) type = int(type) method = int(method) payments.create(amount, email, method, type, notes, reference) flash("Thank you!", "success") return payments_get()
def test_create(self): payment_id = payments.create(str(self.amount), self.email, self.method, self.type, self.notes, self.reference) payment = Payment.get(Payment.id == payment_id) self.assertNotEqual(payment.id, self.id) self.assertEqual(payment.amount, self.amount) self.assertEqual(payment.entity.id, self.entity.id) self.assertEqual(payment.source, self.method) self.assertEqual(payment.is_donation, self.is_donation) self.assertEqual(payment.notes, self.notes) self.assertEqual(payment.bank_reference, self.reference) payment.delete_instance()