fix(python): return months_to_show from the JSON API

Go returns months_to_show in /api/adults and /api/juniors; the Python
API did not, so make parity failed on both routes. The Python HTML
pages already had the feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 11:34:20 +02:00
co-authored by Claude Opus 5.5
parent 97f94afa02
commit e7c8101c3b
3 changed files with 14 additions and 3 deletions
+5
View File
@@ -1,5 +1,10 @@
# Changelog # Changelog
## 2026-10-08 11:34 CEST — fix(python): return months_to_show from /api/adults and /api/juniors
- Go already returned `months_to_show` in the JSON API; Python only passed it to its HTML templates. Backported the key so the API contract matches and `make parity` reports 3/3 routes.
- Key files: `legacy/app.py`, `legacy/tests/test_app.py`.
## 2026-10-08 11:34 CEST — fix: VS is always a string, on read and on write ## 2026-10-08 11:34 CEST — fix: VS is always a string, on read and on write
- Go rendered numeric sheet cells with `fmt.Sprint`, so a numeric VS came out as `2.609767878e+09`. Text columns of the payments sheet now go through `sheets.CellString` (plain digits); bank inference uses it too. - Go rendered numeric sheet cells with `fmt.Sprint`, so a numeric VS came out as `2.609767878e+09`. Text columns of the payments sheet now go through `sheets.CellString` (plain digits); bank inference uses it too.
+6 -2
View File
@@ -179,7 +179,9 @@ def api_adults():
datetime.now().strftime("%Y-%m"), datetime.now().strftime("%Y-%m"),
attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT, attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT,
) )
return jsonify(_unwrap_view_model_for_api(vm)) out = _unwrap_view_model_for_api(vm)
out["months_to_show"] = MONTHS_TO_SHOW
return jsonify(out)
@app.route("/api/juniors") @app.route("/api/juniors")
def api_juniors(): def api_juniors():
@@ -203,7 +205,9 @@ def api_juniors():
datetime.now().strftime("%Y-%m"), datetime.now().strftime("%Y-%m"),
attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT, attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT,
) )
return jsonify(_unwrap_view_model_for_api(vm)) out = _unwrap_view_model_for_api(vm)
out["months_to_show"] = MONTHS_TO_SHOW
return jsonify(out)
@app.route("/api/payments") @app.route("/api/payments")
def api_payments(): def api_payments():
+3 -1
View File
@@ -6,7 +6,7 @@ from app import app
EXPECTED_ADULTS_KEYS = { EXPECTED_ADULTS_KEYS = {
"months", "raw_months", "results", "totals", "member_data", "month_labels", "months", "raw_months", "results", "totals", "member_data", "month_labels",
"raw_payments", "credits", "debts", "unmatched", "attendance_url", "raw_payments", "credits", "debts", "unmatched", "attendance_url",
"payments_url", "bank_account", "current_month", "payments_url", "bank_account", "current_month", "months_to_show",
} }
EXPECTED_JUNIORS_KEYS = EXPECTED_ADULTS_KEYS EXPECTED_JUNIORS_KEYS = EXPECTED_ADULTS_KEYS
EXPECTED_PAYMENTS_KEYS = {"grouped_payments", "sorted_people", "attendance_url", "payments_url"} EXPECTED_PAYMENTS_KEYS = {"grouped_payments", "sorted_people", "attendance_url", "payments_url"}
@@ -139,6 +139,7 @@ class TestWebApp(unittest.TestCase):
self.assertIsInstance(data['member_data'], dict) self.assertIsInstance(data['member_data'], dict)
self.assertIsInstance(data['month_labels'], dict) self.assertIsInstance(data['month_labels'], dict)
self.assertIsInstance(data['raw_payments'], dict) self.assertIsInstance(data['raw_payments'], dict)
self.assertIsInstance(data['months_to_show'], int)
@patch('app.get_cached_data', side_effect=_bypass_cache) @patch('app.get_cached_data', side_effect=_bypass_cache)
@patch('app.fetch_sheet_data') @patch('app.fetch_sheet_data')
@@ -166,6 +167,7 @@ class TestWebApp(unittest.TestCase):
self.assertIsInstance(data['member_data'], dict) self.assertIsInstance(data['member_data'], dict)
self.assertIsInstance(data['month_labels'], dict) self.assertIsInstance(data['month_labels'], dict)
self.assertIsInstance(data['raw_payments'], dict) self.assertIsInstance(data['raw_payments'], dict)
self.assertIsInstance(data['months_to_show'], int)
@patch('app.get_cached_data', side_effect=_bypass_cache) @patch('app.get_cached_data', side_effect=_bypass_cache)
@patch('app.fetch_sheet_data') @patch('app.fetch_sheet_data')