Adds landing page at root URL (/) that displays all active products with links to feedback submission forms. This replaces the requirement for users to know direct product URLs. Changes: - Added Product.load_active() method to filter and sort active products alphabetically - Created landing route blueprint with error handling and structured logging - Registered landing blueprint in app factory, replacing old index route - Created landing page template with product list and empty state - Added comprehensive contract tests (6 tests) covering active products, filtering, sorting, XSS prevention - Added integration test for complete user flow from landing page to submission form All 7 tests pass. User Story 1 (P1 - MVP) complete. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
30 lines
966 B
Python
30 lines
966 B
Python
"""Landing page route - product selection"""
|
|
from flask import Blueprint, render_template, current_app
|
|
from app.models.product import Product
|
|
|
|
landing_bp = Blueprint('landing', __name__)
|
|
|
|
|
|
@landing_bp.route('/')
|
|
def index():
|
|
"""Landing page showing all active products for feedback submission
|
|
|
|
Returns:
|
|
Rendered HTML template with:
|
|
- List of active products (if any)
|
|
- Empty state message (if no active products)
|
|
"""
|
|
try:
|
|
products = Product.load_active()
|
|
current_app.logger.info(
|
|
f'Landing page accessed: {len(products)} active products available'
|
|
)
|
|
return render_template('landing/index.html', products=products)
|
|
except Exception as e:
|
|
current_app.logger.error(
|
|
f'Error loading landing page: {e}',
|
|
exc_info=True
|
|
)
|
|
# Graceful degradation - show empty product list
|
|
return render_template('landing/index.html', products=[])
|