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.
This commit is contained in:
apuc committed 2026-11-22 22:38:39 +03:00
1 parent b18e3ea703
commit 37d5d7b366
29 files changed
+2822 -7

No files matched your search

@@ -0,0 +1,40 @@
{% load storefront %}
<article class="product-card">
<a href="{% url 'product' product.slug %}" class="product-media" aria-label="{{ product.name }}">
<div class="product-badges">
{% if product.is_hit %}<span class="badge badge-hit">Хит</span>{% endif %}
{% if product.is_new %}<span class="badge badge-new">Новинка</span>{% endif %}
</div>
{% if product.main_image %}
<img src="{{ product.main_image }}" alt="{{ product.name }}" loading="lazy">
{% else %}
<span class="placeholder">{{ product.name|slice:":1" }}</span>
{% endif %}
</a>
<div class="product-body">
{% if product.brand %}<span class="product-brand">{{ product.brand }}</span>{% endif %}
<h3 class="product-name"><a href="{% url 'product' product.slug %}">{{ product.name }}</a></h3>
<div class="product-price">
<span class="price-now">{{ product.price|money }} ₽</span>
{% if product.old_price %}
<span class="price-old">{{ product.old_price|money }} ₽</span>
{% endif %}
</div>
</div>
<div class="product-actions">
{% if product.stock > 0 %}
<button class="btn btn-outline btn-block btn-sm"
data-add-to-cart
data-id="{{ product.id }}"
data-slug="{{ product.slug }}"
data-name="{{ product.name }}"
data-price="{{ product.price }}"
data-image="{{ product.main_image|default:'' }}"
data-stock="{{ product.stock }}">
В корзину
</button>
{% else %}
<button class="btn btn-outline btn-block btn-sm" disabled>Нет в наличии</button>
{% endif %}
</div>
</article>