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 %}