198 lines
10 KiB
HTML
198 lines
10 KiB
HTML
{% extends "base.html" %}
|
||
{% block title %}Права доступа — Morozovka Portal{% endblock %}
|
||
{% block main_class %}container container-narrow{% endblock %}
|
||
|
||
{% block content %}
|
||
|
||
{% if mode == 'space' %}
|
||
<div class="breadcrumbs-bar">
|
||
<a href="/files">Файлы</a>
|
||
<span class="sep">/</span>
|
||
<a href="/files/space/{{ space.id }}">{{ space.name }}</a>
|
||
<span class="sep">/</span>
|
||
<span class="current">Права доступа</span>
|
||
</div>
|
||
<div class="files-hero">
|
||
<div class="files-hero-left">
|
||
<h1>🔐 Права доступа</h1>
|
||
<p class="subtitle">Пространство «{{ space.name }}»</p>
|
||
</div>
|
||
<div class="files-hero-actions">
|
||
<a href="/files/space/{{ space.id }}" class="btn btn-default">← К пространству</a>
|
||
</div>
|
||
</div>
|
||
{% else %}
|
||
<div class="breadcrumbs-bar">
|
||
<a href="/files">Файлы</a>
|
||
<span class="sep">/</span>
|
||
<a href="/files/space/{{ space.id }}">{{ space.name }}</a>
|
||
<span class="sep">/</span>
|
||
<a href="/files/folder/{{ folder.id }}">{{ folder.name }}</a>
|
||
<span class="sep">/</span>
|
||
<span class="current">Права доступа</span>
|
||
</div>
|
||
<div class="files-hero">
|
||
<div class="files-hero-left">
|
||
<h1>🔐 Права доступа — папка</h1>
|
||
<p class="subtitle">«{{ folder.name }}» в пространстве «{{ space.name }}»</p>
|
||
</div>
|
||
<div class="files-hero-actions">
|
||
<a href="/files/folder/{{ folder.id }}" class="btn btn-default">← К папке</a>
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% if mode == 'space' %}
|
||
<div class="form-card" style="margin-bottom:16px;">
|
||
<h3 style="margin-top:0;font-size:15px;">Владелец пространства</h3>
|
||
<div style="display:flex;justify-content:space-between;align-items:center;padding:10px 0;border-top:1px solid var(--border);">
|
||
<div>
|
||
<div style="color:var(--text);font-weight:600;font-size:14px;">{{ owner.full_name or owner.username }}</div>
|
||
<div style="color:var(--text-muted);font-size:12px;">@{{ owner.username }}</div>
|
||
</div>
|
||
<span style="padding:3px 10px;border-radius:10px;background:#a371f7;color:#fff;font-size:11px;font-weight:700;text-transform:uppercase;">Владелец</span>
|
||
</div>
|
||
<p style="color:var(--text-muted);font-size:12px;margin:8px 0 0;line-height:1.5;">
|
||
Владелец всегда имеет полные права. Роли ниже применяются к остальным пользователям. Если явных записей нет — действует <strong>видимость пространства</strong>: <code>{{ space.visibility }}</code>.
|
||
</p>
|
||
</div>
|
||
|
||
<div class="form-card" style="margin-bottom:20px;">
|
||
<h3 style="margin-top:0;font-size:15px;">Добавить / обновить доступ</h3>
|
||
<form action="/files/space/{{ space.id }}/acl/add" method="POST">
|
||
<div class="form-row">
|
||
<div class="form-group">
|
||
<label>Логин пользователя</label>
|
||
<input type="text" name="username" placeholder="username" required>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Роль</label>
|
||
<select name="role">
|
||
<option value="viewer">Viewer — просмотр и скачивание</option>
|
||
<option value="editor">Editor — загрузка, удаление, редактирование</option>
|
||
<option value="manager">Manager — + управление правами</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-actions" style="margin-top:8px;padding-top:8px;">
|
||
<button type="submit" class="btn btn-primary">Добавить / обновить</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<div class="files-section">
|
||
<div class="files-section-head">
|
||
<h2>👥 Пользователи с доступом <span class="count">{{ acl_entries|length }}</span></h2>
|
||
</div>
|
||
{% if acl_entries %}
|
||
<table class="meta-table">
|
||
<thead>
|
||
<tr><th>Пользователь</th><th>Роль</th><th>Действия</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for entry, u in acl_entries %}
|
||
<tr>
|
||
<td>
|
||
<div style="font-weight:600;">{{ u.full_name or u.username }}</div>
|
||
<div style="color:var(--text-muted);font-size:12px;">@{{ u.username }}</div>
|
||
</td>
|
||
<td>
|
||
<span style="padding:3px 10px;border-radius:10px;font-size:11px;font-weight:700;text-transform:uppercase;
|
||
{% if entry.role == 'manager' %}background:#d29922;color:#000;
|
||
{% elif entry.role == 'editor' %}background:#1f6feb;color:#fff;
|
||
{% else %}background:#30363d;color:#e6edf3;{% endif %}">
|
||
{{ entry.role }}
|
||
</span>
|
||
</td>
|
||
<td>
|
||
<form action="/files/space/{{ space.id }}/acl/{{ entry.id }}/remove" method="POST" style="display:inline;" onsubmit="return confirm('Убрать доступ?');">
|
||
<button type="submit" class="btn btn-danger btn-sm">Удалить</button>
|
||
</form>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
{% else %}
|
||
<div class="files-empty">
|
||
<div class="icon">👥</div>
|
||
<h3>Явных записей нет</h3>
|
||
<p>Действует видимость пространства: <code>{{ space.visibility }}</code>. Добавьте пользователей выше для гранулярного контроля.</p>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
|
||
{% else %}
|
||
|
||
<div class="form-card" style="margin-bottom:20px;">
|
||
<h3 style="margin-top:0;font-size:15px;">Добавить / обновить доступ на папку</h3>
|
||
<p style="color:var(--text-muted);font-size:13px;line-height:1.5;margin:0 0 14px;">
|
||
Права на папку <strong>перекрывают</strong> права пространства. Если для пользователя нет записи в папке — действуют права пространства.
|
||
</p>
|
||
<form action="/files/folder/{{ folder.id }}/acl/add" method="POST">
|
||
<div class="form-group">
|
||
<label>Логин пользователя</label>
|
||
<input type="text" name="username" placeholder="username" required>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Права</label>
|
||
<div style="display:flex;flex-wrap:wrap;gap:14px;margin-top:4px;">
|
||
<label style="display:flex;align-items:center;gap:6px;color:var(--text);font-size:13px;cursor:pointer;"><input type="checkbox" name="can_view" checked> 👁 Видеть</label>
|
||
<label style="display:flex;align-items:center;gap:6px;color:var(--text);font-size:13px;cursor:pointer;"><input type="checkbox" name="can_upload"> ⬆ Загружать</label>
|
||
<label style="display:flex;align-items:center;gap:6px;color:var(--text);font-size:13px;cursor:pointer;"><input type="checkbox" name="can_delete"> 🗑 Удалять</label>
|
||
<label style="display:flex;align-items:center;gap:6px;color:var(--text);font-size:13px;cursor:pointer;"><input type="checkbox" name="can_manage"> ⚙ Управлять правами</label>
|
||
</div>
|
||
</div>
|
||
<div class="form-actions" style="margin-top:8px;padding-top:8px;">
|
||
<button type="submit" class="btn btn-primary">Добавить / обновить</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<div class="files-section">
|
||
<div class="files-section-head">
|
||
<h2>👥 Пользователи с доступом на папку <span class="count">{{ acl_entries|length }}</span></h2>
|
||
</div>
|
||
{% if acl_entries %}
|
||
<table class="meta-table">
|
||
<thead>
|
||
<tr><th>Пользователь</th><th>Права</th><th>Действия</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for entry, u in acl_entries %}
|
||
<tr>
|
||
<td>
|
||
<div style="font-weight:600;">{{ u.full_name or u.username }}</div>
|
||
<div style="color:var(--text-muted);font-size:12px;">@{{ u.username }}</div>
|
||
</td>
|
||
<td>
|
||
<form action="/files/folder/{{ folder.id }}/acl/{{ entry.id }}/save" method="POST" style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;">
|
||
<label style="display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--text);cursor:pointer;"><input type="checkbox" name="can_view" {% if entry.can_view %}checked{% endif %}> 👁</label>
|
||
<label style="display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--text);cursor:pointer;"><input type="checkbox" name="can_upload" {% if entry.can_upload %}checked{% endif %}> ⬆</label>
|
||
<label style="display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--text);cursor:pointer;"><input type="checkbox" name="can_delete" {% if entry.can_delete %}checked{% endif %}> 🗑</label>
|
||
<label style="display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--text);cursor:pointer;"><input type="checkbox" name="can_manage" {% if entry.can_manage %}checked{% endif %}> ⚙</label>
|
||
<button type="submit" class="btn btn-default btn-sm">Сохранить</button>
|
||
</form>
|
||
</td>
|
||
<td>
|
||
<form action="/files/folder/{{ folder.id }}/acl/{{ entry.id }}/remove" method="POST" style="display:inline;" onsubmit="return confirm('Убрать доступ?');">
|
||
<button type="submit" class="btn btn-danger btn-sm">Удалить</button>
|
||
</form>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
{% else %}
|
||
<div class="files-empty">
|
||
<div class="icon">👥</div>
|
||
<h3>Явных прав на папку нет</h3>
|
||
<p>Действуют права пространства «{{ space.name }}».</p>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
|
||
{% endif %}
|
||
|
||
{% endblock %}
|