204000aabc
Resolve 3 merge conflicts and renumber the automation_hooks migration to follow main's migration chain (036_add_document_translation_fields). Conflicts resolved: - app/api/__init__.py: add automation_router alongside main's new routers - app/utils/settings_service.py: add automation_hooks_enabled alongside compliance_enabled - tests/conftest.py: add AutomationHook alongside AuditLog/ComplianceTemplate imports Migration renumbered: - 027_add_automation_hooks → 037_add_automation_hooks - down_revision: 026_add_scheduled_jobs → 036_add_document_translation_fields Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""View route for the user self-service profile settings page.
|
|
|
|
Route:
|
|
GET /profile — renders the profile settings HTML page (requires login)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from fastapi import Depends, Request
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.models import UserProfile
|
|
from app.utils.i18n import SUPPORTED_LANGUAGES
|
|
from app.views.base import APIRouter, get_db, require_login, templates
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/profile", include_in_schema=False)
|
|
@require_login
|
|
async def profile_page(request: Request, db: Session = Depends(get_db)):
|
|
"""Serve the user profile settings page."""
|
|
user = request.session.get("user") or {}
|
|
user_id = user.get("sub") or user.get("preferred_username") or user.get("email") or user.get("id")
|
|
|
|
profile = None
|
|
if user_id:
|
|
profile = db.query(UserProfile).filter(UserProfile.user_id == user_id).first()
|
|
|
|
return templates.TemplateResponse(
|
|
"profile.html",
|
|
{
|
|
"request": request,
|
|
"profile": profile,
|
|
"supported_languages": SUPPORTED_LANGUAGES,
|
|
},
|
|
)
|