From ceee85caba41a78328ff134c7ec0152881580145 Mon Sep 17 00:00:00 2001 From: Deeman Date: Sat, 21 Feb 2026 01:38:33 +0100 Subject: [PATCH] feat(content): programmatic SEO seed script + lang bug fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add scripts/seed_content.py: inserts EN + DE article templates and 18 cities × 2 language data rows; run with --generate to produce 36 pre-built SEO articles (Germany 8, USA 6, UK 4 cities) each with city-specific financial model overrides for unique content per article - Fix bake_scenario_cards() to accept lang param and pass it to scenario card partials; German articles now render German labels - Fix _generate_from_template() to extract language from data row and pass to calc() and bake_scenario_cards() - Fix article_slug to use {template_slug}-{city_slug} preventing UNIQUE collision when multiple templates generate articles for same city - Fix _rebuild_article() to pass lang to bake_scenario_cards() Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 11 + padelnomics/src/padelnomics/admin/routes.py | 11 +- padelnomics/src/padelnomics/content/routes.py | 6 +- .../src/padelnomics/scripts/seed_content.py | 887 ++++++++++++++++++ 4 files changed, 908 insertions(+), 7 deletions(-) create mode 100644 padelnomics/src/padelnomics/scripts/seed_content.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e5154..e232c43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] +### Added +- content: `scripts/seed_content.py` — seeds two article templates (EN + DE) and 18 cities × 2 language rows into the database; run with `uv run python -m padelnomics.scripts.seed_content --generate` to produce 36 pre-built SEO articles covering Germany (8 cities), USA (6 cities), and UK (4 cities); each city has realistic per-market overrides for rates, rent, utilities, permits, and court configuration so the financial model produces genuinely unique output per article +- content: EN template (`city-padel-cost-en`) at `/padel-cost/{{ city_slug }}` and DE template (`city-padel-cost-de`) at `/padel-kosten/{{ city_slug }}` with Jinja2 Markdown bodies embedding `[scenario:slug:section]` cards for summary, CAPEX, operating, cashflow, and returns + +### Fixed +- content: `bake_scenario_cards()` now accepts a `lang` parameter and passes it to scenario partial templates; previously `lang` was always `undefined`, causing all cards to render with English labels even for German articles +- admin: `_generate_from_template()` extracts `language` from data row and passes it to `calc()` and `bake_scenario_cards()` so German scenario cards use translated CAPEX/OPEX item names +- admin: `_generate_from_template()` now derives `article_slug` as `{template_slug}-{city_slug}` instead of bare `city_slug`; bare slugs caused UNIQUE constraint collisions when multiple templates generated articles for the same city +- admin: `_rebuild_article()` passes `lang` from data row (or `"en"` for manual articles) to `bake_scenario_cards()` so rebuilt articles render correct language labels +- content: removed unused `g` import from `content/routes.py` + ### Changed - planner: full HTMX refactor — replaced 847-line SPA `planner.js` with server-rendered Jinja2 tab partials; planner now uses `hx-post /planner/calculate` + form state; all tab content (CAPEX, Operating, Cash Flow, Returns, Metrics) rendered server-side; Chart.js data embedded as `