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

+79
View File
@@ -0,0 +1,79 @@
{% extends "storefront/base.html" %}
{% load storefront %}
{% block title %}{{ site.site_name }} — одежда и аксессуары{% endblock %}
{% block content %}
{% if banners %}
<div class="hero">
{% with banner=banners.0 %}
{% if banner.image_url %}<img class="hero-image" src="{{ banner.image_url }}" alt="">{% endif %}
<h1>{{ banner.title }}</h1>
<p>{{ site.site_name }}: одежда, обувь и аксессуары. Ассортимент и наличие синхронизированы с 1С.</p>
{% if banner.link_url %}
<a class="btn btn-accent" href="{{ banner.link_url }}">Смотреть</a>
{% else %}
<a class="btn btn-accent" href="{% url 'catalog' %}">Смотреть каталог</a>
{% endif %}
{% endwith %}
</div>
{% else %}
<div class="hero">
<h1>{{ site.site_name }} — вещи, которые носят годами</h1>
<p>Одежда, обувь и аксессуары. Цены и наличие обновляются из 1С в реальном времени.</p>
<a class="btn btn-accent" href="{% url 'catalog' %}">Смотреть каталог</a>
</div>
{% endif %}
{% if categories %}
<section class="section">
<div class="section-head">
<h2>Категории</h2>
<a href="{% url 'catalog' %}">Весь каталог</a>
</div>
<div class="category-grid">
{% for category in categories %}
<a class="category-tile" href="{% url 'catalog' %}?category={{ category.slug }}">
{% if category.image_url %}<img src="{{ category.image_url }}" alt="">{% endif %}
<span>{{ category.name }}</span>
</a>
{% endfor %}
</div>
</section>
{% endif %}
{% if hits %}
<section class="section">
<div class="section-head">
<h2>Хиты продаж</h2>
<a href="{% url 'catalog' %}?ordering=-is_hit">Все хиты</a>
</div>
<div class="product-grid">
{% for product in hits %}
{% include "storefront/_product_card.html" %}
{% endfor %}
</div>
</section>
{% endif %}
{% if new %}
<section class="section">
<div class="section-head">
<h2>Новинки</h2>
<a href="{% url 'catalog' %}?ordering=-created_at">Все новинки</a>
</div>
<div class="product-grid">
{% for product in new %}
{% include "storefront/_product_card.html" %}
{% endfor %}
</div>
</section>
{% endif %}
{% if not hits and not new %}
<div class="empty-state">
<h2>Каталог пока пуст</h2>
<p>Товары появятся после первой синхронизации с 1С.</p>
</div>
{% endif %}
{% endblock %}