Add admin panel, cart, checkout, and digital key delivery

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-25 05:32:05 +03:00
co-authored by Cursor
parent 08cc4b0f1b
commit 54eaff4c70
32 changed files with 1982 additions and 105 deletions
+32
View File
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{% block title %}Админка — {{ app_name }}{% endblock %}</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Syne:wght@500;700;800&family=Manrope:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="/static/css/style.css" />
</head>
<body class="admin-body">
<div class="admin-shell">
<aside class="admin-nav">
<a class="brand" href="/admin">{{ app_name }} Admin</a>
<a href="/admin">Дашборд</a>
<a href="/admin/products">Товары</a>
<a href="/admin/orders">Заказы</a>
<a href="/" target="_blank">Открыть магазин</a>
<form method="post" action="/admin/logout" class="logout-form">
<button type="submit" class="btn btn-ghost btn-tiny">Выйти ({{ admin_user }})</button>
</form>
</aside>
<div class="admin-main">
{% block content %}{% endblock %}
</div>
</div>
</body>
</html>
+56
View File
@@ -0,0 +1,56 @@
{% extends "admin/base.html" %}
{% block title %}Дашборд — {{ app_name }}{% endblock %}
{% block content %}
<div class="section-head">
<h2>Дашборд</h2>
<p>Сводка по магазину</p>
</div>
<div class="admin-stats">
<div class="stat">
<span class="stat-label">Товары</span>
<strong>{{ products_count }}</strong>
</div>
<div class="stat">
<span class="stat-label">Свободные ключи</span>
<strong>{{ keys_free }}</strong>
</div>
<div class="stat">
<span class="stat-label">Заказы</span>
<strong>{{ orders_count }}</strong>
</div>
<div class="stat">
<span class="stat-label">Выручка</span>
<strong>{{ revenue | rub }}</strong>
</div>
</div>
<div class="section-head compact">
<h3>Последние заказы</h3>
</div>
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>ID</th>
<th>Email</th>
<th>Сумма</th>
<th>Статус</th>
</tr>
</thead>
<tbody>
{% for order in recent_orders %}
<tr>
<td><a href="/admin/orders/{{ order.id }}">{{ order.public_id }}</a></td>
<td>{{ order.email }}</td>
<td>{{ order.total | rub }}</td>
<td>{{ order.status }}</td>
</tr>
{% else %}
<tr><td colspan="4">Заказов пока нет</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+44
View File
@@ -0,0 +1,44 @@
{% extends "admin/base.html" %}
{% block title %}Ключи — {{ product.title }}{% endblock %}
{% block content %}
<div class="section-head">
<h2>Ключи: {{ product.title }}</h2>
<p>Свободно: {{ stock }} шт.</p>
</div>
{% if message %}
<p class="flash ok">{{ message }}</p>
{% endif %}
<form method="post" class="stack-form">
<label>
Добавить ключи (по одному на строку)
<textarea name="codes" rows="8" required placeholder="XXXX-YYYY-ZZZZ"></textarea>
</label>
<button class="btn btn-primary" type="submit">Загрузить</button>
</form>
<div class="table-wrap" style="margin-top: 2rem">
<table class="data-table">
<thead>
<tr>
<th>Код</th>
<th>Статус</th>
<th>Order</th>
</tr>
</thead>
<tbody>
{% for key in keys %}
<tr>
<td><code>{{ key.code }}</code></td>
<td>{% if key.is_sold %}sold{% else %}free{% endif %}</td>
<td>{% if key.order_id %}#{{ key.order_id }}{% else %}—{% endif %}</td>
</tr>
{% else %}
<tr><td colspan="3">Ключей пока нет</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+35
View File
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Вход в админку — {{ app_name }}</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=Manrope:wght@400;600;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="/static/css/style.css" />
</head>
<body class="admin-body">
<section class="page-section narrow admin-login">
<h1>{{ app_name }} Admin</h1>
<p class="muted">Вход для управления магазином</p>
{% if error %}
<p class="flash error">{{ error }}</p>
{% endif %}
<form method="post" action="/admin/login" class="stack-form">
<label>
Логин
<input type="text" name="username" required autocomplete="username" />
</label>
<label>
Пароль
<input type="password" name="password" required autocomplete="current-password" />
</label>
<button class="btn btn-primary" type="submit">Войти</button>
</form>
</section>
</body>
</html>
+25
View File
@@ -0,0 +1,25 @@
{% extends "admin/base.html" %}
{% block title %}Заказ {{ order.public_id }} — {{ app_name }}{% endblock %}
{% block content %}
<div class="section-head">
<h2>Заказ {{ order.public_id }}</h2>
<p>{{ order.email }} · {{ order.status }} · {{ order.total | rub }}</p>
</div>
{% if order.customer_note %}
<p><strong>Комментарий:</strong> {{ order.customer_note }}</p>
{% endif %}
{% for item in order.items %}
<article class="order-item">
<h3>{{ item.title }} × {{ item.quantity }}</h3>
<p class="muted">{{ item.unit_price | rub }}</p>
{% if item.delivered_codes %}
<pre class="codes">{{ item.delivered_codes }}</pre>
{% endif %}
</article>
{% endfor %}
<a class="btn btn-ghost" href="/admin/orders">К списку</a>
{% endblock %}
+36
View File
@@ -0,0 +1,36 @@
{% extends "admin/base.html" %}
{% block title %}Заказы — {{ app_name }}{% endblock %}
{% block content %}
<div class="section-head">
<h2>Заказы</h2>
<p>Последние 100 заказов</p>
</div>
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>Номер</th>
<th>Email</th>
<th>Сумма</th>
<th>Статус</th>
<th>Дата</th>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<td><a href="/admin/orders/{{ order.id }}">{{ order.public_id }}</a></td>
<td>{{ order.email }}</td>
<td>{{ order.total | rub }}</td>
<td>{{ order.status }}</td>
<td>{{ order.created_at }}</td>
</tr>
{% else %}
<tr><td colspan="5">Заказов нет</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+70
View File
@@ -0,0 +1,70 @@
{% extends "admin/base.html" %}
{% block title %}{% if product %}Редактирование{% else %}Новый товар{% endif %} — {{ app_name }}{% endblock %}
{% block content %}
<div class="section-head">
<h2>{% if product %}Редактировать товар{% else %}Новый товар{% endif %}</h2>
</div>
{% if error %}
<p class="flash error">{{ error }}</p>
{% endif %}
<form method="post" class="stack-form admin-form">
<label>
Название
<input name="title" required value="{{ form.title if form else product.title if product else '' }}" />
</label>
<label>
Slug
<input name="slug" required value="{{ form.slug if form else product.slug if product else '' }}" />
</label>
<label>
Краткое описание
<input name="short_description" required maxlength="300" value="{{ form.short_description if form else product.short_description if product else '' }}" />
</label>
<label>
Описание
<textarea name="description" rows="4">{{ form.description if form else product.description if product else '' }}</textarea>
</label>
<label>
Цена (₽)
<input name="price" required value="{{ form.price if form else product.price if product else '' }}" />
</label>
<label>
Категория
<select name="category_slug" required>
{% for category in categories %}
<option value="{{ category.slug }}"
{% if (form.category_slug if form else product.category_slug if product else '') == category.slug %}selected{% endif %}>
{{ category.name }}
</option>
{% endfor %}
</select>
</label>
<label>
Градиент карточки
<select name="image_gradient">
{% set g = form.image_gradient if form else product.image_gradient if product else 'mint' %}
{% for opt in ['mint', 'coral', 'ink', 'sand'] %}
<option value="{{ opt }}" {% if g == opt %}selected{% endif %}>{{ opt }}</option>
{% endfor %}
</select>
</label>
<label>
Подпись доставки
<input name="delivery_note" value="{{ form.delivery_note if form else product.delivery_note if product else 'Мгновенная выдача' }}" />
</label>
<label class="check">
<input type="checkbox" name="is_featured" value="1"
{% if form %}{% if form.is_featured %}checked{% endif %}{% elif product and product.is_featured %}checked{% endif %} />
В избранном
</label>
<label class="check">
<input type="checkbox" name="is_active" value="1"
{% if form %}{% if form.is_active %}checked{% endif %}{% elif not product or product.is_active %}checked{% endif %} />
Активен
</label>
<button class="btn btn-primary" type="submit">Сохранить</button>
</form>
{% endblock %}
+48
View File
@@ -0,0 +1,48 @@
{% extends "admin/base.html" %}
{% block title %}Товары — {{ app_name }}{% endblock %}
{% block content %}
<div class="section-head row-head">
<div>
<h2>Товары</h2>
<p>Каталог и остатки ключей</p>
</div>
<a class="btn btn-primary" href="/admin/products/new">Добавить товар</a>
</div>
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>Название</th>
<th>Цена</th>
<th>Остаток</th>
<th>Статус</th>
<th></th>
</tr>
</thead>
<tbody>
{% for product in products %}
<tr>
<td>
<strong>{{ product.title }}</strong>
<div class="muted">{{ product.slug }}</div>
</td>
<td>{{ product.price | rub }}</td>
<td>{{ stock_map.get(product.id, 0) }}</td>
<td>{% if product.is_active %}active{% else %}hidden{% endif %}</td>
<td class="actions">
<a href="/admin/products/{{ product.id }}/edit">Изменить</a>
<a href="/admin/products/{{ product.id }}/keys">Ключи</a>
<form method="post" action="/admin/products/{{ product.id }}/delete" onsubmit="return confirm('Удалить товар?')">
<button type="submit" class="linkish">Удалить</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="5">Товаров нет</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+6 -4
View File
@@ -21,11 +21,13 @@
<header class="site-header">
<a class="brand" href="/">{{ app_name }}</a>
<nav class="nav" aria-label="Основное меню">
<a href="#catalog">Каталог</a>
<a href="#how">Как купить</a>
<a href="#support">Поддержка</a>
<a href="/#catalog">Каталог</a>
<a href="/lookup">Мой заказ</a>
<a href="/#how">Как купить</a>
</nav>
<a class="header-cta" href="#catalog">В каталог</a>
<a class="header-cta cart-link" href="/cart">
Корзина{% if cart_count %} <span class="cart-badge">{{ cart_count }}</span>{% endif %}
</a>
</header>
<main>{% block content %}{% endblock %}</main>
<footer class="site-footer" id="support">
+57
View File
@@ -0,0 +1,57 @@
{% extends "base.html" %}
{% block title %}Корзина — {{ app_name }}{% endblock %}
{% block content %}
<section class="page-section">
<div class="section-head">
<h2>Корзина</h2>
<p>Проверьте товары перед оформлением</p>
</div>
{% if not items %}
<p class="empty">Корзина пуста. <a href="/#catalog">Перейти в каталог</a></p>
{% else %}
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>Товар</th>
<th>Цена</th>
<th>Кол-во</th>
<th>Сумма</th>
<th></th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>
<a href="/product/{{ item.product.slug }}">{{ item.product.title }}</a>
<div class="muted">В наличии: {{ item.stock }}</div>
</td>
<td>{{ item.product.price | rub }}</td>
<td>
<form method="post" action="/cart/update" class="inline-form">
<input type="hidden" name="product_id" value="{{ item.product.id }}" />
<input type="number" name="quantity" min="0" max="{{ item.stock }}" value="{{ item.quantity }}" />
<button class="btn btn-ghost btn-tiny" type="submit">OK</button>
</form>
</td>
<td>{{ item.line_total | rub }}</td>
<td>
<form method="post" action="/cart/remove/{{ item.product.id }}">
<button class="btn btn-ghost btn-tiny" type="submit">Удалить</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="cart-summary">
<div class="price big">Итого: {{ total | rub }}</div>
<a class="btn btn-primary" href="/checkout">Оформить заказ</a>
</div>
{% endif %}
</section>
{% endblock %}
+37
View File
@@ -0,0 +1,37 @@
{% extends "base.html" %}
{% block title %}Оформление — {{ app_name }}{% endblock %}
{% block content %}
<section class="page-section narrow">
<div class="section-head">
<h2>Оформление заказа</h2>
<p>Демо-оплата: заказ сразу выдаёт цифровые коды</p>
</div>
{% if error %}
<p class="flash error">{{ error }}</p>
{% endif %}
<ul class="checkout-list">
{% for item in items %}
<li>
<span>{{ item.product.title }} × {{ item.quantity }}</span>
<strong>{{ item.line_total | rub }}</strong>
</li>
{% endfor %}
</ul>
<p class="price big">К оплате: {{ total | rub }}</p>
<form method="post" action="/checkout" class="stack-form">
<label>
Email для выдачи
<input type="email" name="email" required placeholder="you@email.com" />
</label>
<label>
Комментарий (необязательно)
<textarea name="note" rows="3" placeholder="Например: регион аккаунта"></textarea>
</label>
<button class="btn btn-primary" type="submit">Оплатить и получить коды</button>
</form>
</section>
{% endblock %}
+20 -14
View File
@@ -6,11 +6,11 @@
<p class="brand-mark">{{ app_name }}</p>
<h1>Цифровые товары без ожидания</h1>
<p class="hero-lead">
Ключи, софт и подарочные карты — оплатил и сразу получил доступ в личном кабинете.
Ключи, софт и подарочные карты — оплатил и сразу получил код.
</p>
<div class="hero-actions">
<a class="btn btn-primary" href="#catalog">Смотреть каталог</a>
<a class="btn btn-ghost" href="#how">Как это работает</a>
<a class="btn btn-ghost" href="/lookup">Найти заказ</a>
</div>
</div>
<div class="hero-visual" aria-hidden="true">
@@ -46,14 +46,18 @@
<div class="featured-rail" aria-label="Избранное">
{% for product in featured %}
<article class="product product-featured gradient-{{ product.image_gradient }} reveal">
<div class="product-media"></div>
<a class="product-media" href="/product/{{ product.slug }}"></a>
<div class="product-body">
<p class="product-tag">{{ product.delivery_note }}</p>
<h3>{{ product.title }}</h3>
<h3><a href="/product/{{ product.slug }}">{{ product.title }}</a></h3>
<p>{{ product.short_description }}</p>
<div class="product-meta">
<span class="price">{{ product.price | rub }}</span>
<button type="button" class="btn btn-small" data-buy="{{ product.slug }}">Купить</button>
<form method="post" action="/cart/add/{{ product.id }}">
<button type="submit" class="btn btn-small" {% if stock_map.get(product.id, 0) < 1 %}disabled{% endif %}>
{% if stock_map.get(product.id, 0) < 1 %}Нет в наличии{% else %}В корзину{% endif %}
</button>
</form>
</div>
</div>
</article>
@@ -64,14 +68,18 @@
<div class="product-grid">
{% for product in products %}
<article class="product gradient-{{ product.image_gradient }} reveal">
<div class="product-media"></div>
<a class="product-media" href="/product/{{ product.slug }}"></a>
<div class="product-body">
<p class="product-tag">{{ product.delivery_note }}</p>
<h3>{{ product.title }}</h3>
<h3><a href="/product/{{ product.slug }}">{{ product.title }}</a></h3>
<p>{{ product.short_description }}</p>
<div class="product-meta">
<span class="price">{{ product.price | rub }}</span>
<button type="button" class="btn btn-small" data-buy="{{ product.slug }}">Купить</button>
<form method="post" action="/cart/add/{{ product.id }}">
<button type="submit" class="btn btn-small" {% if stock_map.get(product.id, 0) < 1 %}disabled{% endif %}>
{% if stock_map.get(product.id, 0) < 1 %}Нет в наличии{% else %}В корзину{% endif %}
</button>
</form>
</div>
</div>
</article>
@@ -90,20 +98,18 @@
<li>
<span class="step-num">01</span>
<h3>Выберите товар</h3>
<p>Ключ, подписка или карта пополнения из каталога.</p>
<p>Добавьте ключ, подписку или карту в корзину.</p>
</li>
<li>
<span class="step-num">02</span>
<h3>Оплатите</h3>
<p>Безопасная оплата картой или через доступные методы.</p>
<h3>Оформите заказ</h3>
<p>Укажите email — туда привязывается выдача.</p>
</li>
<li>
<span class="step-num">03</span>
<h3>Получите сразу</h3>
<p>Код или доступ приходят автоматически после оплаты.</p>
<p>Коды открываются на странице заказа мгновенно.</p>
</li>
</ol>
</section>
<div class="toast" id="toast" hidden role="status" aria-live="polite"></div>
{% endblock %}
+25
View File
@@ -0,0 +1,25 @@
{% extends "base.html" %}
{% block title %}Мой заказ — {{ app_name }}{% endblock %}
{% block content %}
<section class="page-section narrow">
<div class="section-head">
<h2>Найти заказ</h2>
<p>Введите номер заказа и email</p>
</div>
{% if error %}
<p class="flash error">{{ error }}</p>
{% endif %}
<form method="post" action="/lookup" class="stack-form">
<label>
Номер заказа
<input type="text" name="public_id" required placeholder="например A1B2C3D4" />
</label>
<label>
Email
<input type="email" name="email" required />
</label>
<button class="btn btn-primary" type="submit">Найти</button>
</form>
</section>
{% endblock %}
+31
View File
@@ -0,0 +1,31 @@
{% extends "base.html" %}
{% block title %}Заказ {{ order.public_id }} — {{ app_name }}{% endblock %}
{% block content %}
<section class="page-section narrow">
<div class="section-head">
<h2>Заказ {{ order.public_id }}</h2>
<p>Статус: <strong>{{ order.status }}</strong> · {{ order.email }}</p>
</div>
<p class="price big">Сумма: {{ order.total | rub }}</p>
{% for item in order.items %}
<article class="order-item">
<h3>{{ item.title }} × {{ item.quantity }}</h3>
<p class="muted">{{ item.unit_price | rub }} за шт.</p>
{% if item.delivered_codes %}
<div class="codes">
<p class="product-tag">Ваши коды</p>
<pre>{{ item.delivered_codes }}</pre>
</div>
{% else %}
<p>Коды ещё не выданы.</p>
{% endif %}
</article>
{% endfor %}
<p class="muted">Сохраните номер заказа — его можно открыть позже в разделе «Мой заказ».</p>
<a class="btn btn-ghost" href="/">На главную</a>
</section>
{% endblock %}
+21
View File
@@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block title %}Открыть заказ — {{ app_name }}{% endblock %}
{% block content %}
<section class="page-section narrow">
<div class="section-head">
<h2>Доступ к заказу {{ public_id }}</h2>
<p>Введите email, указанный при покупке</p>
</div>
{% if error %}
<p class="flash error">{{ error }}</p>
{% endif %}
<form method="post" action="/order/{{ public_id }}" class="stack-form">
<label>
Email
<input type="email" name="email" required />
</label>
<button class="btn btn-primary" type="submit">Открыть</button>
</form>
</section>
{% endblock %}
+32
View File
@@ -0,0 +1,32 @@
{% extends "base.html" %}
{% block title %}{{ product.title }} — {{ app_name }}{% endblock %}
{% block content %}
<section class="page-section product-page">
<a class="back-link" href="/#catalog">К каталогу</a>
<div class="product-layout">
<div class="product-hero-media gradient-{{ product.image_gradient }}">
<div class="product-media tall"></div>
</div>
<div class="product-info">
<p class="product-tag">{{ product.delivery_note }}</p>
<h1>{{ product.title }}</h1>
<p class="lead">{{ product.short_description }}</p>
<p>{{ product.description }}</p>
<p class="stock-line">В наличии: {{ stock }} шт.</p>
<div class="buy-row">
<span class="price big">{{ product.price | rub }}</span>
<form method="post" action="/cart/add/{{ product.id }}" class="inline-form">
<label class="qty-label">
Кол-во
<input type="number" name="quantity" min="1" max="{{ stock if stock > 0 else 1 }}" value="1" {% if stock < 1 %}disabled{% endif %} />
</label>
<button class="btn btn-primary" type="submit" {% if stock < 1 %}disabled{% endif %}>
{% if stock < 1 %}Нет в наличии{% else %}В корзину{% endif %}
</button>
</form>
</div>
</div>
</div>
</section>
{% endblock %}