feat(loyalty): Phase 4.1 — T&C via CMS integration
Some checks failed
CI / ruff (push) Successful in 12s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has been cancelled

Add support for linking a loyalty program's Terms & Conditions to a
CMS page, replacing the simple terms_text textarea with a scalable
content source that supports rich HTML, multi-language, and store
overrides.

- Migration loyalty_006: adds terms_cms_page_slug column to
  loyalty_programs (nullable, String 200).
- Model + schemas: new field on LoyaltyProgram, ProgramCreate,
  ProgramUpdate, ProgramResponse.
- Program form: new "CMS Page Slug" input field with hint text,
  placed above the legacy terms_text (now labeled as "fallback").
- Enrollment page: when terms_cms_page_slug is set, JS fetches the
  CMS page content via /storefront/cms/pages/{slug} and displays
  rendered HTML in the modal. Falls back to terms_text when no slug.
- i18n: 3 new keys in 4 locales (terms_cms_page, terms_cms_page_hint,
  terms_fallback_hint).

Legacy terms_text field preserved as fallback for existing programs.

342 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-11 20:26:22 +02:00
parent 24219e4d9a
commit 4c1608f78a
10 changed files with 93 additions and 15 deletions

View File

@@ -0,0 +1,35 @@
"""loyalty 006 - add terms_cms_page_slug to loyalty_programs
Allows linking a loyalty program's T&C to a CMS page instead of
using the simple terms_text field. When set, the enrollment page
resolves the slug to a full CMS page. The legacy terms_text is
kept as a fallback for existing programs.
Revision ID: loyalty_006
Revises: loyalty_005
Create Date: 2026-04-11
"""
import sqlalchemy as sa
from alembic import op
revision = "loyalty_006"
down_revision = "loyalty_005"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
"loyalty_programs",
sa.Column(
"terms_cms_page_slug",
sa.String(200),
nullable=True,
comment="CMS page slug for full T&C content (overrides terms_text when set)",
),
)
def downgrade() -> None:
op.drop_column("loyalty_programs", "terms_cms_page_slug")