Skip to content

fix: Move minimum-donation JSON out of global scripts file

stephen requested to merge move-minimum-donation-json into main

A previous commit fixed an issue in which "minimum donation" values were set in various places throughout the codebase as one-off magic numbers, despite that value being set in CiviCRM and retrieved via API (or, well, via a mock of that API). This was achieved in part by embedding a script tag in the HTML, before the inclusion of the main site JS file, which contained a JSON string containing relevant minimum-donation data. This JSON string was created by running the form.minimum_donation Django variable through the Jinja2 tojson and safe filters.

This is all well and good, except that the "form" in form.minimum_donation is the donate form... which is only available on the donate page. However, this JSON string's script tag was included in scripts.html, which is included on the footer of every page on the site. This had the unintended effect of causing every page but the main index page to crash.

This has been rectified by moving the script tag in question to the bottom of donate.html.jinja, inside the pagescripts block, which is the intended location for page-specific scripts like this.

Merge request reports