Commit Graph
7 Commits
Author SHA1 Message Date
apuc a64d567cff Switch the demo catalog and copy to an electronics store
The shop sells tech, not clothing, so the demo data and page copy now
match that:

- seven categories: smartphones, laptops, tablets, audio, TVs, home
  appliances, accessories
- fifteen products with real-looking specs (screen, CPU, RAM, storage,
  energy class, warranty) instead of apparel attributes
- hero copy and meta description talk about tech and appliances
- banner updated in place by position/sort_order, so re-seeding does not
  leave a stale duplicate

Catalog polish:
- brand list and price range now follow the selected category instead of
  the whole catalog

Tests: storefront fixtures renamed to the tech domain; suite is 61
passing.
2026-11-22 22:46:56 +03:00
apuc 37d5d7b366 Add the customer storefront on Django templates
Pages are rendered server-side (SEO, no build step), the interactive
parts talk to the existing REST API from the browser:

- home: banners, categories, hits and new arrivals
- catalog: filters (category, brand, price, stock), search, sorting,
  pagination, filter chips with one-click removal
- product card: gallery, price with discount, stock, characteristics,
  related products
- cart: localStorage, quantity controls, live totals
- checkout: contacts, delivery, promo code, bonuses, order submission
  with Idempotency-Key, success screen
- login: OTP by phone (debug code shown in dev) and phone/password
- account: profile, orders, addresses, bonuses through the API with JWT
- static pages from the admin

Supporting pieces:
- apps/storefront app with views, urls, templates and static CSS/JS
- money/discount/attribute template filters
- seed_demo management command with demo catalog, banners and pages
- Cyrillic search fallback for SQLite: local DB does not fold case for
  non-ASCII, production PostgreSQL does

Tests: 16 storefront cases (pages, filters, search, ordering, 404s,
filters formatting); the suite is 61 passing.
2026-11-22 22:38:39 +03:00
apuc b18e3ea703 Add a Telegram bot client with setup tooling for admin alerts
Bot API client (apps/integration/telegram.py):
- sendMessage, getMe, getUpdates over requests, no extra dependencies
- Telegram API errors are surfaced with the provider description
  ("chat not found", "bot was blocked") instead of a bare HTTP status
- messages longer than the Bot API limit are truncated with a marker

Notifications:
- notifications.py now goes through the client; failures are logged and
  never break the exchange

Setup helpers:
- telegram_check: verifies the token, prints the bot name, sends a test
  message, and suggests chats when chat_id is missing
- telegram_chats: lists chats that wrote to the bot, --apply saves the
  chat_id when exactly one chat is known
- admin action "Detect chat_id from bot messages" does the same in the UI,
  with explicit messages for no chats, many chats and API errors
- admin help text explains the BotFather -> /start -> test flow

Docs: Telegram setup section, command reference and limitations
(4096-char limit, negative chat_id for groups/channels, no internet =
no Telegram).

Tests: 12 new cases for the client, both commands and the admin action;
the suite is 45 passing.
2026-11-22 22:25:13 +03:00
apuc e1cc6dbaad Add exchange monitoring controls: stop sync and admin alerts
Stop a running exchange:
- SyncRun gets a Celery task_id and a "stopped" status
- The task is bound and passes its id into the run, so the admin can
  revoke it with app.control.revoke(..., terminate=True)
- Admin action "Stop synchronization" reports stopped, already finished,
  runs without a task id and broker errors separately
- A stopped run is never overwritten by the task result

Alerts about exchange failures:
- NotificationSettings singleton (admin section): on/off, email
  recipients, Telegram bot token and chat id, per-event flags
- notifications.py sends through email and Telegram, best effort:
  delivery errors are logged and never break the exchange
- Fired on catalog apply failure (pull from 1C and inbound push) and on
  outbox messages that exhausted retries
- Admin action "Send test notification" verifies the channels
- SMTP settings added to base.py and .env.example so email really works
  in production; SMS is not implemented (no SMS gateway in the project)

Tests: 11 new cases (email/Telegram delivery, flags, outbox dead-letter,
stop semantics); the suite is 33 passing.
2026-11-22 22:19:43 +03:00
apuc 3b3e5c429a Serve an offline API reference at /api/docs/
The Swagger UI page was blank on networks where the jsdelivr CDN is
unreachable (here the proxy answers 407), so /api/docs/ now returns a
server-rendered reference built from the same OpenAPI schema: inline
CSS/JS, no external requests, search across methods.

- Extract the renderer into apps/common/api_docs.py
- Add api_docs_view and route it to /api/docs/
- Move Swagger UI to /api/swagger/, keep ReDoc at /api/redoc/
- Let export_api_docs reuse the shared renderer (new search field)
- Update the docs entry points in docs/architecture.md
2026-11-22 22:09:41 +03:00
apuc f6c61ff8da Document the API in Swagger with tags, parameters and examples
- Add OpenAPI tags for the seven API groups and a full description
  (auth, error envelope, pagination, idempotency) in SPECTACULAR_SETTINGS
- Annotate every endpoint with @extend_schema: summary, description,
  query parameters, request/response examples and error responses
- Add shared schema helpers in apps/common/schema.py: ErrorEnvelope,
  error_responses(), pagination and catalog filter parameters
- Document JWT login and token refresh that simplejwt ships without docs
- Add ReDoc at /api/redoc/ next to Swagger UI at /api/docs/
- Add export_api_docs management command rendering the schema into a
  standalone HTML reference (no CDN) and commit docs/api-reference.html
- Describe the documentation entry points in docs/architecture.md

Schema validates cleanly: 41 operations, 0 warnings.
2026-11-22 22:06:21 +03:00
apuc 756f40353b Add Django backend, 1C integration, deploy config and API docs
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.
2026-11-22 21:54:16 +03:00