0a51001791
Co-authored-by: Cursor <cursoragent@cursor.com>
115 lines
6.6 KiB
HTML
115 lines
6.6 KiB
HTML
{% extends "admin/layout.html" %}
|
|
|
|
{% block title %}Рекламные баннеры — Админка{% endblock %}
|
|
{% block admin_title %}Рекламные баннеры{% endblock %}
|
|
{% block admin_subtitle %}<p class="admin-main__subtitle">Баннеры на главной, в кабинете и в подвале</p>{% endblock %}
|
|
|
|
{% block admin_content %}
|
|
<div class="admin-panel folder-create">
|
|
<h2 class="admin-panel__title">Добавить баннер</h2>
|
|
<form method="post" class="auth-form folder-create__form">
|
|
<div class="form-group">
|
|
<label for="title">Название (для админки)</label>
|
|
<input type="text" id="title" name="title" required minlength="2" placeholder="Промо лето">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="image_url">URL изображения</label>
|
|
<input type="url" id="image_url" name="image_url" required placeholder="https://example.com/banner.jpg">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="link_url">Ссылка при клике (необязательно)</label>
|
|
<input type="url" id="link_url" name="link_url" placeholder="https://example.com">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="alt_text">Alt-текст</label>
|
|
<input type="text" id="alt_text" name="alt_text" placeholder="Описание баннера">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="position">Позиция</label>
|
|
<select id="position" name="position" class="form-select">
|
|
{% for key, label in positions.items() %}
|
|
<option value="{{ key }}">{{ label }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="sort_order">Порядок (меньше — выше)</label>
|
|
<input type="number" id="sort_order" name="sort_order" value="0">
|
|
</div>
|
|
<label class="form-checkbox">
|
|
<input type="checkbox" name="is_active" checked>
|
|
<span>Активен</span>
|
|
</label>
|
|
<button type="submit" class="btn btn--primary">Добавить баннер</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="admin-table-wrap">
|
|
<table class="admin-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Баннер</th>
|
|
<th>Позиция</th>
|
|
<th>Статус</th>
|
|
<th>Действия</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for banner in banners %}
|
|
<tr>
|
|
<td>
|
|
<div class="banner-preview">
|
|
<img src="{{ banner.image_url }}" alt="" class="banner-preview__img">
|
|
<div>
|
|
<strong>{{ banner.title }}</strong>
|
|
{% if banner.link_url %}<br><small>{{ banner.link_url }}</small>{% endif %}
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>{{ banner.position_label }}</td>
|
|
<td>
|
|
{% if banner.is_active %}
|
|
<span class="badge badge--success">активен</span>
|
|
{% else %}
|
|
<span class="badge badge--muted">выключен</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<form method="post" action="{{ url_for('admin.edit_banner', banner_id=banner.id) }}" class="banner-edit-form">
|
|
<input type="text" name="title" value="{{ banner.title }}" required minlength="2" class="form-inline-input">
|
|
<input type="url" name="image_url" value="{{ banner.image_url }}" required class="form-inline-input">
|
|
<input type="url" name="link_url" value="{{ banner.link_url or '' }}" placeholder="Ссылка" class="form-inline-input">
|
|
<select name="position" class="form-select form-select--sm">
|
|
{% for key, label in positions.items() %}
|
|
<option value="{{ key }}" {% if banner.position == key %}selected{% endif %}>{{ label }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<input type="number" name="sort_order" value="{{ banner.sort_order }}" class="form-inline-input form-inline-input--sm">
|
|
<label class="form-checkbox form-checkbox--inline">
|
|
<input type="checkbox" name="is_active" {% if banner.is_active %}checked{% endif %}>
|
|
<span>Активен</span>
|
|
</label>
|
|
<button type="submit" class="btn btn--ghost btn--sm">Сохранить</button>
|
|
</form>
|
|
<div class="banner-actions">
|
|
<form method="post" action="{{ url_for('admin.toggle_banner', banner_id=banner.id) }}">
|
|
<button type="submit" class="btn btn--ghost btn--sm">
|
|
{% if banner.is_active %}Выключить{% else %}Включить{% endif %}
|
|
</button>
|
|
</form>
|
|
<form method="post" action="{{ url_for('admin.delete_banner', banner_id=banner.id) }}" onsubmit="return confirm('Удалить баннер?');">
|
|
<button type="submit" class="btn btn--danger btn--sm">Удалить</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="4">Баннеров пока нет</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endblock %}
|