Files
orion/app/modules/messaging/routes/pages/store.py
Samir Boulahtit f20266167d
Some checks failed
CI / ruff (push) Failing after 7s
CI / pytest (push) Failing after 1s
CI / architecture (push) Failing after 9s
CI / dependency-scanning (push) Successful in 27s
CI / audit (push) Successful in 8s
CI / docs (push) Has been skipped
fix(lint): auto-fix ruff violations and tune lint rules
- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.)
- Added ignore rules for patterns intentional in this codebase:
  E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from),
  SIM108/SIM105/SIM117 (readability preferences)
- Added per-file ignores for tests and scripts
- Excluded broken scripts/rename_terminology.py (has curly quotes)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 23:10:42 +01:00

95 lines
2.8 KiB
Python

# app/modules/messaging/routes/pages/store.py
"""
Messaging Store Page Routes (HTML rendering).
Store pages for messaging management:
- Messages list
- Conversation detail
- Email templates
"""
from fastapi import APIRouter, Depends, Path, Request
from fastapi.responses import HTMLResponse
from sqlalchemy.orm import Session
from app.api.deps import get_current_store_from_cookie_or_header, get_db
from app.modules.core.utils.page_context import get_store_context
from app.modules.tenancy.models import User
from app.templates_config import templates
router = APIRouter()
# ============================================================================
# MESSAGING
# ============================================================================
@router.get(
"/{store_code}/messages", response_class=HTMLResponse, include_in_schema=False
)
async def store_messages_page(
request: Request,
store_code: str = Path(..., description="Store code"),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):
"""
Render messages page.
JavaScript loads conversations and messages via API.
"""
return templates.TemplateResponse(
"messaging/store/messages.html",
get_store_context(request, db, current_user, store_code),
)
@router.get(
"/{store_code}/messages/{conversation_id}",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_message_detail_page(
request: Request,
store_code: str = Path(..., description="Store code"),
conversation_id: int = Path(..., description="Conversation ID"),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):
"""
Render message detail page.
Shows the full conversation thread.
"""
return templates.TemplateResponse(
"messaging/store/messages.html",
get_store_context(
request, db, current_user, store_code, conversation_id=conversation_id
),
)
# ============================================================================
# EMAIL TEMPLATES
# ============================================================================
@router.get(
"/{store_code}/email-templates",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_email_templates_page(
request: Request,
store_code: str = Path(..., description="Store code"),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):
"""
Render store email templates customization page.
Allows stores to override platform email templates.
"""
return templates.TemplateResponse(
"messaging/store/email-templates.html",
get_store_context(request, db, current_user, store_code),
)