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

+60
View File
@@ -0,0 +1,60 @@
{% extends "storefront/base.html" %}
{% load static %}
{% block title %}Вход — {{ site.site_name }}{% endblock %}
{% block content %}
<div style="max-width:460px;margin:0 auto">
<div class="page-head">
<h1>Вход в личный кабинет</h1>
<p>Войдите по номеру телефона — код придёт в SMS. Пароль нужен, только если вы его задавали.</p>
</div>
<div class="account-panel">
<div class="account-nav" style="flex-direction:row;gap:8px;margin-bottom:20px">
<button type="button" class="active" data-tab="otp">Код из SMS</button>
<button type="button" data-tab="password">Телефон и пароль</button>
</div>
<form data-otp-form>
<div class="field">
<label for="otp_phone">Номер телефона</label>
<input id="otp_phone" name="phone" required autocomplete="tel" placeholder="+7 900 123-45-67">
</div>
<button class="btn btn-accent btn-block" type="button" data-request-code>Получить код</button>
<div data-code-block hidden>
<div class="field" style="margin-top:16px">
<label for="otp_code">Код из SMS</label>
<input id="otp_code" name="code" inputmode="numeric" autocomplete="one-time-code"
placeholder="4 цифры" maxlength="8">
</div>
<button class="btn btn-accent btn-block" type="submit">Войти</button>
<div class="form-note" data-code-note></div>
</div>
<div class="form-error" data-otp-error hidden></div>
</form>
<form data-password-form hidden>
<div class="field">
<label for="login_phone">Номер телефона</label>
<input id="login_phone" name="phone" required autocomplete="username">
</div>
<div class="field">
<label for="login_password">Пароль</label>
<input id="login_password" name="password" type="password" required autocomplete="current-password">
</div>
<button class="btn btn-accent btn-block" type="submit">Войти</button>
<div class="form-error" data-password-error hidden></div>
</form>
<p class="form-note" style="margin-top:18px">
Нет аккаунта? Он создастся автоматически при первом входе по коду.
</p>
</div>
</div>
{% endblock %}
{% block scripts %}
<script src="{% static 'storefront/js/login-page.js' %}" defer></script>
{% endblock %}