Add folders with password sharing and email invites
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Папки — PhotoHost{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="page-header">
|
||||
<div class="container">
|
||||
<h1 class="page-header__title">Мои папки</h1>
|
||||
<p class="page-header__subtitle">Создавайте папки, делитесь ссылками, защищайте паролем и приглашайте пользователей по email.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% include "partials/alerts.html" %}
|
||||
|
||||
<section class="admin-section">
|
||||
<div class="container">
|
||||
<div class="admin-panel folder-create">
|
||||
<h2 class="admin-panel__title">Создать папку</h2>
|
||||
<form method="post" action="{{ url_for('folders.create_folder') }}" class="auth-form folder-create__form">
|
||||
<div class="form-group">
|
||||
<label for="name">Название</label>
|
||||
<input type="text" id="name" name="name" required minlength="2" placeholder="Отпуск 2025">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="access_password">Пароль доступа (необязательно)</label>
|
||||
<input type="password" id="access_password" name="access_password" minlength="4" placeholder="для приватной папки">
|
||||
</div>
|
||||
<label class="form-checkbox">
|
||||
<input type="checkbox" name="is_private" checked>
|
||||
<span>Приватная папка (доступ по ссылке, паролю или приглашению)</span>
|
||||
</label>
|
||||
<button type="submit" class="btn btn--primary">Создать папку</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2 class="section-title">Мои папки</h2>
|
||||
{% if owned_folders %}
|
||||
<div class="folder-grid">
|
||||
{% for folder in owned_folders %}
|
||||
<article class="folder-card">
|
||||
<div class="folder-card__icon">📁</div>
|
||||
<h3 class="folder-card__title">{{ folder.name }}</h3>
|
||||
<p class="folder-card__meta">
|
||||
{{ folder.photo_count }} фото
|
||||
{% if folder.is_private %} · приватная{% endif %}
|
||||
{% if folder.has_password %} · с паролем{% endif %}
|
||||
</p>
|
||||
<div class="folder-card__actions">
|
||||
<a href="{{ url_for('folders.view_folder', folder_id=folder.id) }}" class="btn btn--ghost btn--sm">Открыть</a>
|
||||
<a href="{{ url_for('folders.folder_settings', folder_id=folder.id) }}" class="btn btn--ghost btn--sm">Настройки</a>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-state__icon">📁</div>
|
||||
<h3>У вас пока нет папок</h3>
|
||||
<p>Создайте первую папку для организации фото</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if shared_folders %}
|
||||
<h2 class="section-title" style="margin-top: 40px;">Общие со мной</h2>
|
||||
<div class="folder-grid">
|
||||
{% for folder in shared_folders %}
|
||||
<article class="folder-card folder-card--shared">
|
||||
<div class="folder-card__icon">🤝</div>
|
||||
<h3 class="folder-card__title">{{ folder.name }}</h3>
|
||||
<p class="folder-card__meta">@{{ folder.owner.username }} · {{ folder.photo_count }} фото</p>
|
||||
<div class="folder-card__actions">
|
||||
<a href="{{ url_for('folders.view_folder', folder_id=folder.id) }}" class="btn btn--ghost btn--sm">Открыть</a>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,22 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Пароль папки — {{ folder.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="auth-section">
|
||||
<div class="container auth-container">
|
||||
<div class="auth-card">
|
||||
<h1 class="auth-card__title">Папка «{{ folder.name }}»</h1>
|
||||
<p class="auth-card__subtitle">Введите пароль для доступа</p>
|
||||
{% include "partials/alerts.html" %}
|
||||
<form method="post" class="auth-form">
|
||||
<div class="form-group">
|
||||
<label for="password">Пароль папки</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn--primary btn--full">Открыть</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,142 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Настройки — {{ folder.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="page-header">
|
||||
<div class="container">
|
||||
<h1 class="page-header__title">Настройки папки</h1>
|
||||
<p class="page-header__subtitle">{{ folder.name }}</p>
|
||||
<div class="page-header__actions">
|
||||
<a href="{{ url_for('folders.view_folder', folder_id=folder.id) }}" class="btn btn--ghost">← К папке</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="admin-section">
|
||||
<div class="container">
|
||||
{% include "partials/alerts.html" %}
|
||||
|
||||
<div class="admin-grid">
|
||||
<div class="admin-panel">
|
||||
<h2 class="admin-panel__title">Основные настройки</h2>
|
||||
<form method="post" class="auth-form">
|
||||
<input type="hidden" name="action" value="save">
|
||||
<div class="form-group">
|
||||
<label for="name">Название</label>
|
||||
<input type="text" id="name" name="name" value="{{ folder.name }}" required minlength="2">
|
||||
</div>
|
||||
<label class="form-checkbox">
|
||||
<input type="checkbox" name="is_private" {% if folder.is_private %}checked{% endif %}>
|
||||
<span>Приватная папка</span>
|
||||
</label>
|
||||
<div class="form-group">
|
||||
<label for="access_password">Новый пароль доступа</label>
|
||||
<input type="password" id="access_password" name="access_password" minlength="4" placeholder="оставьте пустым, если не меняете">
|
||||
</div>
|
||||
{% if folder.has_password %}
|
||||
<label class="form-checkbox">
|
||||
<input type="checkbox" name="remove_password">
|
||||
<span>Убрать пароль</span>
|
||||
</label>
|
||||
{% endif %}
|
||||
<button type="submit" class="btn btn--primary">Сохранить</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="admin-panel">
|
||||
<h2 class="admin-panel__title">Ссылка для sharing</h2>
|
||||
<p class="folder-share-url">{{ share_url }}</p>
|
||||
<div class="folder-card__actions">
|
||||
<button type="button" class="btn btn--ghost btn--sm copy-btn" data-url="{{ share_url }}">Копировать</button>
|
||||
<form method="post" style="display:inline">
|
||||
<input type="hidden" name="action" value="regenerate_link">
|
||||
<button type="submit" class="btn btn--ghost btn--sm">Обновить ссылку</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-panel" style="margin-top: 24px;">
|
||||
<h2 class="admin-panel__title">Пригласить по email</h2>
|
||||
<form method="post" action="{{ url_for('folders.invite_member', folder_id=folder.id) }}" class="auth-form folder-create__form">
|
||||
<div class="form-group">
|
||||
<label for="email">Email пользователя</label>
|
||||
<input type="email" id="email" name="email" required placeholder="user@example.com">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="role">Роль</label>
|
||||
<select id="role" name="role" class="form-select">
|
||||
<option value="viewer">Просмотр</option>
|
||||
<option value="editor">Редактор (загрузка и удаление)</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn--primary">Добавить / пригласить</button>
|
||||
</form>
|
||||
<p class="folder-hint">Если пользователь ещё не зарегистрирован, доступ откроется автоматически после регистрации с этим email.</p>
|
||||
</div>
|
||||
|
||||
{% if members %}
|
||||
<div class="admin-panel" style="margin-top: 24px;">
|
||||
<h2 class="admin-panel__title">Участники</h2>
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr><th>Пользователь</th><th>Email</th><th>Роль</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for member in members %}
|
||||
<tr>
|
||||
<td>{{ member.user.username }}</td>
|
||||
<td>{{ member.user.email }}</td>
|
||||
<td>{{ 'Редактор' if member.role == 'editor' else 'Просмотр' }}</td>
|
||||
<td>
|
||||
<form method="post" action="{{ url_for('folders.remove_member', folder_id=folder.id, user_id=member.user_id) }}">
|
||||
<button type="submit" class="btn btn--danger btn--sm">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if invites %}
|
||||
<div class="admin-panel" style="margin-top: 24px;">
|
||||
<h2 class="admin-panel__title">Ожидают регистрации</h2>
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr><th>Email</th><th>Роль</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for invite in invites %}
|
||||
<tr>
|
||||
<td>{{ invite.email }}</td>
|
||||
<td>{{ 'Редактор' if invite.role == 'editor' else 'Просмотр' }}</td>
|
||||
<td>
|
||||
<form method="post" action="{{ url_for('folders.remove_invite', folder_id=folder.id, invite_id=invite.id) }}">
|
||||
<button type="submit" class="btn btn--danger btn--sm">Отменить</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="admin-panel admin-panel--danger" style="margin-top: 24px;">
|
||||
<h2 class="admin-panel__title">Удалить папку</h2>
|
||||
<p class="folder-hint">Все фото внутри папки будут удалены безвозвратно.</p>
|
||||
<form method="post" onsubmit="return confirm('Удалить папку и все фото в ней?');">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<button type="submit" class="btn btn--danger">Удалить папку</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,54 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ folder.name }} — PhotoHost{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="page-header">
|
||||
<div class="container">
|
||||
<h1 class="page-header__title">📁 {{ folder.name }}</h1>
|
||||
<p class="page-header__subtitle">
|
||||
{% if folder.is_private %}Приватная папка{% else %}Публичная папка{% endif %}
|
||||
{% if folder.has_password %} · защищена паролем{% endif %}
|
||||
· {{ photos|length }} фото
|
||||
</p>
|
||||
<div class="page-header__actions">
|
||||
<a href="{{ url_for('folders.list_folders') }}" class="btn btn--ghost">← Все папки</a>
|
||||
{% if folder.owner_id == current_user.id %}
|
||||
<a href="{{ url_for('folders.folder_settings', folder_id=folder.id) }}" class="btn btn--ghost">Настройки</a>
|
||||
{% endif %}
|
||||
<button type="button" class="btn btn--ghost copy-btn" data-url="{{ share_url }}">Копировать ссылку</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% include "partials/alerts.html" %}
|
||||
|
||||
{% if can_edit %}
|
||||
<section id="upload" class="upload-section">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Загрузить в папку</h2>
|
||||
<form action="{{ url_for('main.upload') }}" method="post" enctype="multipart/form-data" class="upload-form" id="uploadForm">
|
||||
<input type="hidden" name="folder_id" value="{{ folder.id }}">
|
||||
<div class="dropzone" id="dropzone">
|
||||
<input type="file" name="photo" id="photoInput" accept="image/png,image/jpeg,image/gif,image/webp,image/bmp" hidden>
|
||||
<p class="dropzone__title">Перетащите фото сюда</p>
|
||||
<p class="dropzone__hint">или нажмите для выбора файла</p>
|
||||
<div class="dropzone__preview" id="preview" hidden>
|
||||
<img id="previewImg" alt="Предпросмотр">
|
||||
<span id="previewName"></span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn--primary" id="submitBtn" disabled>Загрузить</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section class="gallery-section">
|
||||
<div class="container">
|
||||
{% with photos=photos, empty_title='В папке пока нет фото', empty_text='Загрузите первое изображение' %}
|
||||
{% include "partials/photo_gallery.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -9,6 +9,7 @@
|
||||
<h1 class="page-header__title">Личный кабинет</h1>
|
||||
<p class="page-header__subtitle">Привет, {{ current_user.username }}! Управляйте своими фотографиями.</p>
|
||||
<div class="page-header__actions">
|
||||
<a href="{{ url_for('folders.list_folders') }}" class="btn btn--primary">Мои папки</a>
|
||||
<a href="{{ url_for('cabinet.profile') }}" class="btn btn--ghost">Настройки профиля</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,6 +58,27 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% if folders %}
|
||||
<section class="gallery-section">
|
||||
<div class="container">
|
||||
<div class="gallery-header">
|
||||
<h2 class="section-title">Недавние папки</h2>
|
||||
<a href="{{ url_for('folders.list_folders') }}" class="btn btn--ghost btn--sm">Все папки</a>
|
||||
</div>
|
||||
<div class="folder-grid">
|
||||
{% for folder in folders %}
|
||||
<article class="folder-card">
|
||||
<div class="folder-card__icon">📁</div>
|
||||
<h3 class="folder-card__title">{{ folder.name }}</h3>
|
||||
<p class="folder-card__meta">{{ folder.photo_count }} фото</p>
|
||||
<a href="{{ url_for('folders.view_folder', folder_id=folder.id) }}" class="btn btn--ghost btn--sm">Открыть</a>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section class="gallery-section">
|
||||
<div class="container">
|
||||
<div class="gallery-header">
|
||||
|
||||
Reference in New Issue
Block a user