main features
This commit is contained in:
204
.patch_backup_20250810_164608/templates/ui/cabinet.html
Normal file
204
.patch_backup_20250810_164608/templates/ui/cabinet.html
Normal file
@@ -0,0 +1,204 @@
|
||||
{% load static ui_extras %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Кабинет</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link href="{% static 'style.css' %}" rel="stylesheet">
|
||||
<style>
|
||||
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", sans-serif; margin:0; background:#f7f7fb; color:#111; }
|
||||
.topbar { display:flex; gap:16px; align-items:center; padding:14px 18px; background:#111827; color:#fff; }
|
||||
.topbar a { color:#cfe3ff; text-decoration:none; }
|
||||
.container { max-width:1100px; margin:24px auto; padding:0 16px; }
|
||||
.heading { display:flex; align-items:flex-end; gap:12px; margin:8px 0 18px; }
|
||||
.heading h1 { margin:0; font-size:24px; }
|
||||
.muted { color:#6b7280; font-size:14px; }
|
||||
.card { background:#fff; border:1px solid #e5e7eb; border-radius:12px; padding:18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
|
||||
.grid { display:grid; gap:16px; }
|
||||
.grid-2 { grid-template-columns: 1fr 1fr; }
|
||||
dl { display:grid; grid-template-columns: 200px 1fr; gap:8px 14px; margin: 0; }
|
||||
dt { font-weight:600; color:#374151; }
|
||||
dd { margin:0; color:#111827; }
|
||||
.pill { display:inline-block; padding:4px 10px; border-radius:999px; background:#eef2ff; color:#3730a3; font-size:12px; margin:2px 6px 2px 0; }
|
||||
.row { display:flex; gap:18px; align-items:center; }
|
||||
.avatar { width:96px; height:96px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:32px; background:#e5e7eb; color:#374151; }
|
||||
.avatar img { width:96px; height:96px; object-fit:cover; border-radius:50%; display:block; }
|
||||
.form { display:grid; gap:14px; }
|
||||
.form input[type="text"], .form select, .form textarea { width:100%; border:1px solid #d1d5db; border-radius:8px; padding:10px 12px; font:inherit; background:#fff; }
|
||||
.btnrow { display:flex; gap:10px; margin-top:8px; }
|
||||
.btn { display:inline-block; padding:10px 14px; border-radius:10px; border:1px solid #d1d5db; background:#fff; cursor:pointer; font-weight:600; color:#111; }
|
||||
.btn-primary { background:#2563eb; color:#fff; border-color:#2563eb; }
|
||||
.btn-outline { background:#fff; color:#111; border-color:#d1d5db; }
|
||||
.messages { list-style:none; padding:0; margin:0 0 16px; }
|
||||
.messages li { padding:10px 12px; margin-bottom:8px; border-radius:10px; }
|
||||
.messages li.success { background:#ecfdf5; color:#065f46; border:1px solid #a7f3d0; }
|
||||
.messages li.error { background:#fef2f2; color:#991b1b; border:1px solid #fecaca; }
|
||||
.messages li.info { background:#eff6ff; color:#1e40af; border:1px solid #bfdbfe; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="topbar">
|
||||
<div style="flex:1 1 auto;">
|
||||
Здравствуйте, <strong>{{ request.session.user_full_name|default:request.session.user_email }}</strong>!
|
||||
</div>
|
||||
<nav style="display:flex; gap:14px;">
|
||||
<a href="{% url 'index' %}">Главная</a>
|
||||
<a href="{% url 'cabinet' %}">Кабинет</a>
|
||||
<a href="{% url 'profiles' %}">Каталог</a>
|
||||
<a href="{% url 'logout' %}">Выход</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
{% if messages %}
|
||||
<ul class="messages">
|
||||
{% for message in messages %}
|
||||
<li class="{{ message.tags }}">{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<div class="heading">
|
||||
<h1>Кабинет</h1>
|
||||
{% if has_profile %}
|
||||
<span class="muted">профиль создан</span>
|
||||
{% else %}
|
||||
<span class="muted">профиль ещё не создан</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="grid grid-2">
|
||||
<!-- Аккаунт -->
|
||||
<section class="card">
|
||||
<h2 class="muted" style="margin-top:0;">Данные аккаунта</h2>
|
||||
<div class="row" style="margin-bottom:14px;">
|
||||
<div class="avatar">
|
||||
{% if request.session.user_email %}
|
||||
<img src="{{ request.session.user_email|gravatar_url:96 }}" alt="">
|
||||
{% else %}
|
||||
{{ request.session.user_full_name|default:request.session.user_email|initial }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-weight:700;">{{ request.session.user_full_name|default:"Без имени" }}</div>
|
||||
<div class="muted">{{ request.session.user_email }}</div>
|
||||
<div class="pill" style="margin-top:6px;">{{ request.session.user_role|default:"CLIENT" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="form" method="post" action="{% url 'cabinet' %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action" value="update_name">
|
||||
<label for="full_name">Имя / ФИО</label>
|
||||
<input id="full_name" name="full_name" type="text" value="{{ request.session.user_full_name|default_if_none:'' }}" placeholder="Ваше имя">
|
||||
<div class="btnrow">
|
||||
<button class="btn btn-primary" type="submit">Сохранить имя</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<!-- Фото профиля -->
|
||||
<section class="card">
|
||||
<h2 class="muted" style="margin-top:0;">Фото профиля</h2>
|
||||
<div class="row">
|
||||
<div class="avatar">
|
||||
{% if profile and profile.photo_url %}
|
||||
<img src="{{ profile.photo_url }}" alt="">
|
||||
{% else %}
|
||||
{% if request.session.user_email %}
|
||||
<img src="{{ request.session.user_email|gravatar_url:96 }}" alt="">
|
||||
{% else %}
|
||||
{{ request.session.user_full_name|default:request.session.user_email|initial }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<form method="post" action="{% url 'cabinet_upload_photo' %}" enctype="multipart/form-data" style="display:flex; gap:10px; align-items:center;">
|
||||
{% csrf_token %}
|
||||
<input type="file" name="photo" accept="image/*" required>
|
||||
<button class="btn btn-primary" type="submit">Загрузить</button>
|
||||
</form>
|
||||
|
||||
<form method="post" action="{% url 'cabinet_delete_photo' %}" style="margin-left:auto;">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-outline" type="submit">Удалить фото</button>
|
||||
</form>
|
||||
</div>
|
||||
<p class="muted" style="margin-top:8px;">Если сервер не поддерживает загрузку, вы увидите соответствующее сообщение. Пока используется Gravatar/инициалы.</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{% if not has_profile or not profile %}
|
||||
<section class="card" style="margin-top:16px;" aria-labelledby="section-create">
|
||||
<h2 id="section-create" class="muted" style="margin-top:0;">Создать профиль</h2>
|
||||
|
||||
<form class="form" method="post" action="{% url 'cabinet' %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action" value="create_profile">
|
||||
|
||||
<div style="display:grid; grid-template-columns: 1fr 1fr; gap:16px;">
|
||||
<div>
|
||||
<label for="gender">Пол</label>
|
||||
<select id="gender" name="gender" required>
|
||||
<option value="">— выберите —</option>
|
||||
<option value="male">Мужской</option>
|
||||
<option value="female">Женский</option>
|
||||
<option value="other">Другое</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="city">Город</label>
|
||||
<input id="city" name="city" type="text" required placeholder="Москва">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="languages">Языки</label>
|
||||
<input id="languages" name="languages" type="text" placeholder="ru,en">
|
||||
<small class="muted">Несколько — через запятую</small>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="interests">Интересы</label>
|
||||
<input id="interests" name="interests" type="text" placeholder="music,travel">
|
||||
<small class="muted">Несколько — через запятую</small>
|
||||
</div>
|
||||
|
||||
<div class="btnrow">
|
||||
<button class="btn btn-primary" type="submit">Создать профиль</button>
|
||||
<a class="btn btn-outline" href="{% url 'cabinet' %}">Сбросить</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
{% else %}
|
||||
<section class="card" style="margin-top:16px;">
|
||||
<h2 class="muted" style="margin-top:0;">Данные профиля</h2>
|
||||
<dl>
|
||||
<dt>Пол</dt><dd>{{ profile.gender|default:"—" }}</dd>
|
||||
<dt>Город</dt><dd>{{ profile.city|default:"—" }}</dd>
|
||||
<dt>Языки</dt>
|
||||
<dd>
|
||||
{% if profile.languages %}
|
||||
{% for lang in profile.languages %}<span class="pill">{{ lang }}</span>{% endfor %}
|
||||
{% else %} — {% endif %}
|
||||
</dd>
|
||||
<dt>Интересы</dt>
|
||||
<dd>
|
||||
{% if profile.interests %}
|
||||
{% for it in profile.interests %}<span class="pill">{{ it }}</span>{% endfor %}
|
||||
{% else %} — {% endif %}
|
||||
</dd>
|
||||
<dt>ID профиля</dt><dd><code>{{ profile.id }}</code></dd>
|
||||
<dt>ID пользователя</dt><dd><code>{{ profile.user_id }}</code></dd>
|
||||
</dl>
|
||||
<p class="muted" style="margin-top:8px;">Редактирование полей профиля появится, как только сервер добавит PATCH /profiles/v1/profiles/me.</p>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user