fix: Fix custom donation field regression preventing custom payments
When a user donates money through the standard donation form, the form field custom_donation
is either edited directly by the user, or set by the donation_amount
buttons above it (and a little bit of JavaScript).
At some point during development, the server-side validation for that field came to expect not the name custom_donation
but donation_amount
instead. This was likely not noticed right away because the form field was not being written to the page using Django template form variables, but by simply writing the HTML that it would render instead, leaving a content-view disconnect.
In order to fix this issue, and in order to implement this form field in a future-proof way that will evince an issue much faster if such a regression occurs in the future, the following changes have been made:
-
tordonate.forms.DonorInfoForm
now contains the information necessary to write the field directly to the template, and is named appropriately. - Explicit validation of this field is performed on the server, including against the minimum donation amount (validation was previously only being performed against whether the donation value was sufficient for their selected perk)
- The form template has been updated such that
custom_donation
is written to the page using template tags, ensuring it has a 1:1 relationship with its model on the server, reducing the chance of future regression errors - Tests have been updated to reflect these changes, and extended to cover the new validation