Backend (Django 4.2 + DRF): - accounts: phone OTP login, JWT, profile, addresses - catalog: categories, products, images, filters, search, hits/new/related - orders: creation with Idempotency-Key, stock reservation, status history, cancel - loyalty: bonus accounts, promo codes, gift certificates - payments: payment records and YooKassa webhook handling - content: static pages, banners, site settings - integration: 1C exchange (catalog sync, order push via outbox, statuses, bonuses) - common: error envelope, pagination, request-id, integration auth, admin dashboard Infrastructure: Dockerfile, docker-compose (Postgres, Redis, Celery worker/beat, Nginx), requirements split by environment, OpenAPI contracts for site and 1C, architecture doc. Tests: 22 pytest cases covering catalog, orders, idempotency, OTP, integration.
21 lines
635 B
Python
21 lines
635 B
Python
from django.db import connection
|
|
from django.http import JsonResponse
|
|
from django.utils import timezone
|
|
|
|
|
|
def health(request):
|
|
"""Liveness/readiness probe used by Docker and monitoring."""
|
|
database_ok = True
|
|
try:
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("SELECT 1")
|
|
except Exception: # pragma: no cover - depends on runtime environment
|
|
database_ok = False
|
|
|
|
payload = {
|
|
"status": "ok" if database_ok else "degraded",
|
|
"database": database_ok,
|
|
"time": timezone.now().isoformat(),
|
|
}
|
|
return JsonResponse(payload, status=200 if database_ok else 503)
|