Add user auth, personal cabinet, admin panel and first admin bootstrap

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-06 22:20:09 +03:00
parent c6a7ecfc4c
commit 61e7290ce8
26 changed files with 1351 additions and 108 deletions
+9
View File
@@ -0,0 +1,9 @@
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<section class="container alerts">
{% for category, message in messages %}
<div class="alert alert--{{ category }}">{{ message }}</div>
{% endfor %}
</section>
{% endif %}
{% endwith %}
+50
View File
@@ -0,0 +1,50 @@
{% if photos %}
<div class="gallery">
{% for photo in photos %}
<article class="photo-card" data-id="{{ photo.id }}">
<div class="photo-card__image-wrap">
<img
src="{{ photo.url }}"
alt="{{ photo.original_name }}"
class="photo-card__image"
loading="lazy"
>
<div class="photo-card__overlay">
<button type="button" class="btn btn--ghost btn--sm copy-btn" data-url="{{ request.url_root.rstrip('/') }}{{ photo.url }}">
Копировать ссылку
</button>
<a href="{{ photo.url }}" target="_blank" class="btn btn--ghost btn--sm">Открыть</a>
</div>
</div>
<div class="photo-card__info">
<span class="photo-card__name" title="{{ photo.original_name }}">{{ photo.original_name }}</span>
<div class="photo-card__meta">
<span>{{ photo.size_human }}</span>
<span>{{ photo.created_at.strftime('%d.%m.%Y %H:%M') }}</span>
</div>
{% if show_owner and photo.owner %}
<div class="photo-card__owner">@{{ photo.owner.username }}</div>
{% endif %}
{% if delete_mode == 'admin' %}
<form action="{{ url_for('admin.delete_photo', photo_id=photo.id) }}" method="post" class="photo-card__delete" onsubmit="return confirm('Удалить это фото?');">
<button type="submit" class="btn btn--danger btn--sm">Удалить</button>
</form>
{% elif current_user.is_authenticated and (current_user.is_admin or photo.user_id == current_user.id) %}
<form action="{{ url_for('main.delete_photo', photo_id=photo.id) }}" method="post" class="photo-card__delete" onsubmit="return confirm('Удалить это фото?');">
<button type="submit" class="btn btn--danger btn--sm">Удалить</button>
</form>
{% endif %}
</div>
</article>
{% endfor %}
</div>
{% else %}
<div class="empty-state">
<div class="empty-state__icon">🖼️</div>
<h3>{{ empty_title or 'Пока нет фотографий' }}</h3>
<p>{{ empty_text or 'Загрузите первое изображение — оно появится здесь' }}</p>
{% if empty_link %}
<a href="{{ empty_link }}" class="btn btn--primary">{{ empty_link_text or 'Загрузить фото' }}</a>
{% endif %}
</div>
{% endif %}