GivingForecast Python Script ================================ .. admonition:: :doc:`View the Code` Suggestion: Right-click the link and use the "Open link in a new window" selection, then arrange the windows so you can view them side by side. Install on the Menu -------------------- Once this report is running as you want it, you can install it on the menu by clicking the Add to Menu link on the page. Use something like `#roles=Deacon,Admin` to restrict viewers if needed. Code Review --------------- ``Line 1`` limits who can see and run this report. ``Line 3`` allows the code to use .NET DateTime functionality. ``Lines 5-6`` load the content for the HTML shell and style sheet for the report. See :func:`TextContent`. ``Line 7`` loads the cached JSON data produced with the GivingForecastData Python script. The cached data allows the report to run instantly. See :func:`DynamicDataFromJson`. ``Lines 9-11`` define a function called FmtNumber which takes a value and returns the number as a string suitable for display. The number is formatted with no decimal places and a comma as a thousand's separator. If the value is `None` an empty string is returned. ``Lines 13-14`` define a function called `SafeDiv` which prevents divide by zero errors. Note that the `num` and `dem` arguments stand for numerator and denominator. ``Lines 16-24`` defines a function called `NewRow` which produces a single HTML table row of values. See :func:`SpaceCamelCase`. The dynamic data called `row` is an argument passed in and contains the column values for the row. ``Lines 26-28`` fetches the three rows of HTML passing in the data needed for each row. `data.Combined` is needed to do the % of Total figures. ``Lines 29-35`` prints the final report combining all the individual elements into the Html template.