refactor(db): консолидация миграций и рефакторинг кода

Объединены изменения из промежуточных миграций в начальные миграции для упрощения истории базы данных.
Удалены миграции: accounts/0002, discounts/0002, orders/0003-0004, products/0002-0005, user_roles/0002, system_settings/0001-0002, integrations/0001-0002.
Добавлена автоматическая creation пользователя при установке пароля.
Обновлен UI страницы установки пароля с кастомным стилем.
Добавлен conditional rendering для кнопки синхронизации Recommerce.
Исправлены редиректы с 'index' на '/' в accounts views.
Добавлена проверка request.tenant в navbar и authenticate метод в auth backend.
This commit is contained in:
2026-01-14 16:30:28 +03:00
parent e7672588c6
commit caeb3f80bd
31 changed files with 238 additions and 558 deletions

View File

@@ -1,35 +1,108 @@
{% extends 'base.html' %}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Установка пароля</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
border-radius: 12px;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
padding: 40px;
max-width: 400px;
width: 100%;
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 24px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
color: #333;
font-weight: 500;
margin-bottom: 8px;
}
input[type="password"] {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 14px;
}
input[type="password"]:focus {
outline: none;
border-color: #667eea;
}
.btn {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 6px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
}
.btn:hover {
opacity: 0.9;
}
.messages {
margin-bottom: 20px;
}
.messages .error {
background: #fee;
color: #c33;
padding: 10px;
border-radius: 6px;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>Установка пароля</h1>
<p class="subtitle">для {{ tenant.name }}</p>
{% block title %}Установка пароля{% endblock %}
{% if messages %}
<div class="messages">
{% for message in messages %}
<div class="{{ message.tags }}">{{ message }}</div>
{% endfor %}
{% endif %}
{% block content %}
<div class="container">
<div class="form-container">
<h2 class="text-center mb-4">Установка пароля</h2>
<!-- Приветственное сообщение -->
<div class="alert alert-info">
<strong>Добро пожаловать!</strong> Ваш магазин <strong>{{ tenant.name }}</strong> активирован.
<br>Установите пароль для входа в систему.
</div>
<div class="tab-content">
<div class="tab-pane fade show active" id="setup-password">
<form method="post">
{% csrf_token %}
{% include 'accounts/password_input.html' with field_name='password1' field_label='Пароль' required=True %}
{% include 'accounts/password_input.html' with field_name='password2' field_label='Подтверждение пароля' required=True %}
<button type="submit" class="btn btn-primary w-100">Установить пароль и войти</button>
</form>
<!-- Информация -->
<div class="text-center mt-3">
<small class="text-muted">
После установки пароля вы автоматически войдете в свой магазин.
</small>
</div>
<form method="post">
{% csrf_token %}
<div class="form-group">
<label for="id_password1">Пароль</label>
<input type="password" name="password1" id="id_password1" required>
</div>
</div>
<div class="form-group">
<label for="id_password2">Подтвердите пароль</label>
<input type="password" name="password2" id="id_password2" required>
</div>
<button type="submit" class="btn">Установить пароль</button>
</form>
</div>
</div>
{% endblock %}
</body>
</html>